Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » tomcat » util » digester » [javadoc | source]
    1   /* $Id: Rule.java 467222 2006-10-24 03:17:11Z markt $
    2    *
    3    * Licensed to the Apache Software Foundation (ASF) under one or more
    4    * contributor license agreements.  See the NOTICE file distributed with
    5    * this work for additional information regarding copyright ownership.
    6    * The ASF licenses this file to You under the Apache License, Version 2.0
    7    * (the "License"); you may not use this file except in compliance with
    8    * the License.  You may obtain a copy of the License at
    9    * 
   10    *      http://www.apache.org/licenses/LICENSE-2.0
   11    * 
   12    * Unless required by applicable law or agreed to in writing, software
   13    * distributed under the License is distributed on an "AS IS" BASIS,
   14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15    * See the License for the specific language governing permissions and
   16    * limitations under the License.
   17    */ 
   18   
   19   
   20   package org.apache.tomcat.util.digester;
   21   
   22   
   23   import org.xml.sax.Attributes;
   24   
   25   
   26   /**
   27    * Concrete implementations of this class implement actions to be taken when
   28    * a corresponding nested pattern of XML elements has been matched.
   29    */
   30   
   31   public abstract class Rule {
   32   
   33   
   34       // ----------------------------------------------------------- Constructors
   35   
   36   
   37       /**
   38        * Constructor sets the associated Digester.
   39        *
   40        * @param digester The digester with which this rule is associated
   41        * @deprecated The digester instance is now set in the {@link Digester#addRule} method. Use {@link #Rule()} instead.
   42        */
   43       public Rule(Digester digester) {
   44   
   45           super();
   46           setDigester(digester);
   47   
   48       }
   49       
   50       /**
   51        * <p>Base constructor.
   52        * Now the digester will be set when the rule is added.</p>
   53        */
   54       public Rule() {}
   55   
   56   
   57       // ----------------------------------------------------- Instance Variables
   58   
   59   
   60       /**
   61        * The Digester with which this Rule is associated.
   62        */
   63       protected Digester digester = null;
   64   
   65   
   66       /**
   67        * The namespace URI for which this Rule is relevant, if any.
   68        */
   69       protected String namespaceURI = null;
   70   
   71   
   72       // ------------------------------------------------------------- Properties
   73   
   74   
   75       /**
   76        * Return the Digester with which this Rule is associated.
   77        */
   78       public Digester getDigester() {
   79   
   80           return (this.digester);
   81   
   82       }
   83       
   84       /**
   85        * Set the <code>Digester</code> with which this <code>Rule</code> is associated.
   86        */
   87       public void setDigester(Digester digester) {
   88           
   89           this.digester = digester;
   90           
   91       }
   92   
   93       /**
   94        * Return the namespace URI for which this Rule is relevant, if any.
   95        */
   96       public String getNamespaceURI() {
   97   
   98           return (this.namespaceURI);
   99   
  100       }
  101   
  102   
  103       /**
  104        * Set the namespace URI for which this Rule is relevant, if any.
  105        *
  106        * @param namespaceURI Namespace URI for which this Rule is relevant,
  107        *  or <code>null</code> to match independent of namespace.
  108        */
  109       public void setNamespaceURI(String namespaceURI) {
  110   
  111           this.namespaceURI = namespaceURI;
  112   
  113       }
  114   
  115   
  116       // --------------------------------------------------------- Public Methods
  117   
  118   
  119       /**
  120        * This method is called when the beginning of a matching XML element
  121        * is encountered.
  122        *
  123        * @param attributes The attribute list of this element
  124        * @deprecated Use the {@link #begin(String,String,Attributes) begin}
  125        *   method with <code>namespace</code> and <code>name</code>
  126        *   parameters instead.
  127        */
  128       public void begin(Attributes attributes) throws Exception {
  129   
  130           ;	// The default implementation does nothing
  131   
  132       }
  133   
  134   
  135       /**
  136        * This method is called when the beginning of a matching XML element
  137        * is encountered. The default implementation delegates to the deprecated
  138        * method {@link #begin(Attributes) begin} without the 
  139        * <code>namespace</code> and <code>name</code> parameters, to retain 
  140        * backwards compatibility.
  141        *
  142        * @param namespace the namespace URI of the matching element, or an 
  143        *   empty string if the parser is not namespace aware or the element has
  144        *   no namespace
  145        * @param name the local name if the parser is namespace aware, or just 
  146        *   the element name otherwise
  147        * @param attributes The attribute list of this element
  148        * @since Digester 1.4
  149        */
  150       public void begin(String namespace, String name, Attributes attributes)
  151           throws Exception {
  152   
  153           begin(attributes);
  154   
  155       }
  156   
  157   
  158       /**
  159        * This method is called when the body of a matching XML element
  160        * is encountered.  If the element has no body, this method is
  161        * not called at all.
  162        *
  163        * @param text The text of the body of this element
  164        * @deprecated Use the {@link #body(String,String,String) body} method
  165        *   with <code>namespace</code> and <code>name</code> parameters
  166        *   instead.
  167        */
  168       public void body(String text) throws Exception {
  169   
  170           ;	// The default implementation does nothing
  171   
  172       }
  173   
  174   
  175       /**
  176        * This method is called when the body of a matching XML element is 
  177        * encountered.  If the element has no body, this method is not called at 
  178        * all. The default implementation delegates to the deprecated method 
  179        * {@link #body(String) body} without the <code>namespace</code> and
  180        * <code>name</code> parameters, to retain backwards compatibility.
  181        *
  182        * @param namespace the namespace URI of the matching element, or an 
  183        *   empty string if the parser is not namespace aware or the element has
  184        *   no namespace
  185        * @param name the local name if the parser is namespace aware, or just 
  186        *   the element name otherwise
  187        * @param text The text of the body of this element
  188        * @since Digester 1.4
  189        */
  190       public void body(String namespace, String name, String text)
  191           throws Exception {
  192   
  193           body(text);
  194   
  195       }
  196   
  197   
  198       /**
  199        * This method is called when the end of a matching XML element
  200        * is encountered.
  201        * 
  202        * @deprecated Use the {@link #end(String,String) end} method with 
  203        *   <code>namespace</code> and <code>name</code> parameters instead.
  204        */
  205       public void end() throws Exception {
  206   
  207           ;	// The default implementation does nothing
  208   
  209       }
  210   
  211   
  212       /**
  213        * This method is called when the end of a matching XML element
  214        * is encountered. The default implementation delegates to the deprecated
  215        * method {@link #end end} without the 
  216        * <code>namespace</code> and <code>name</code> parameters, to retain 
  217        * backwards compatibility.
  218        *
  219        * @param namespace the namespace URI of the matching element, or an 
  220        *   empty string if the parser is not namespace aware or the element has
  221        *   no namespace
  222        * @param name the local name if the parser is namespace aware, or just 
  223        *   the element name otherwise
  224        * @since Digester 1.4
  225        */
  226       public void end(String namespace, String name)
  227           throws Exception {
  228   
  229           end();
  230   
  231       }
  232   
  233   
  234       /**
  235        * This method is called after all parsing methods have been
  236        * called, to allow Rules to remove temporary data.
  237        */
  238       public void finish() throws Exception {
  239   
  240           ;	// The default implementation does nothing
  241   
  242       }
  243   
  244   
  245   }

Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » tomcat » util » digester » [javadoc | source]