You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2004/04/02 03:53:41 UTC

cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester Digester.java

skitching    2004/04/01 17:53:41

  Modified:    digester/src/java/org/apache/commons/digester Digester.java
  Log:
  Keep stack of previously matched rules to avoid calling getMatch()
  in the endElement method. This information may also be useful in
  other ways. Tomcat5 and struts have been successfully tested against
  this patch, and all works ok.
  
  Revision  Changes    Path
  1.99      +13 -2     jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
  
  Index: Digester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- Digester.java	29 Mar 2004 20:34:54 -0000	1.98
  +++ Digester.java	2 Apr 2004 01:53:41 -0000	1.99
  @@ -141,6 +141,16 @@
   
   
       /**
  +     * Stack whose elements are List objects, each containing a list of
  +     * Rule objects as returned from Rules.getMatch(). As each xml element
  +     * in the input is entered, the matching rules are pushed onto this
  +     * stack. After the end tag is reached, the matches are popped again.
  +     * The depth of is stack is therefore exactly the same as the current
  +     * "nesting" level of the input xml. 
  +     */
  +    protected ArrayStack matches = new ArrayStack(10);
  +    
  +    /**
        * The class loader to use for instantiating application objects.
        * If not specified, the context class loader, or the class loader
        * used to load Digester itself, is used, based on the value of the
  @@ -1006,7 +1016,7 @@
           }
   
           // Fire "body" events for all relevant rules
  -        List rules = getRules().match(namespaceURI, match);
  +        List rules = (List) matches.pop();
           if ((rules != null) && (rules.size() > 0)) {
               String bodyText = this.bodyText.toString();
               Substitutor substitutor = getSubstitutor();
  @@ -1256,6 +1266,7 @@
   
           // Fire "begin" events for all relevant rules
           List rules = getRules().match(namespaceURI, match);
  +        matches.push(rules);
           if ((rules != null) && (rules.size() > 0)) {
               Substitutor substitutor = getSubstitutor();
               if (substitutor!= null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org