You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/23 17:50:17 UTC
svn commit: r1138948 -
/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java
Author: simonetripodi
Date: Thu Jun 23 15:50:16 2011
New Revision: 1138948
URL: http://svn.apache.org/viewvc?rev=1138948&view=rev
Log:
[DIGESTER-131] Allow recursive match in ExtendedBaseRules
Modified:
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java
Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java?rev=1138948&r1=1138947&r2=1138948&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java (original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/ExtendedBaseRules.java Thu Jun 23 15:50:16 2011
@@ -195,6 +195,34 @@ public class ExtendedBaseRules
// we keep the list of universal matches separate
List<Rule> universalList = new ArrayList<Rule>( counter );
+ // Universal wildcards ('*') in the middle of the pattern-string
+ List<Rule> recList = null;
+ int parentLastIndex = -1;
+ // temporary parentPattern
+ // we don't want to change anything....
+ String tempParentPattern = parentPattern;
+ // look for pattern. Here, we search the whole
+ // parent. Not ideal, but does the thing....
+ while ( ( parentLastIndex = tempParentPattern.lastIndexOf( '/' ) ) > -1 && recList == null )
+ {
+ recList = this.cache.get( tempParentPattern + "/*/" + pattern.substring( lastIndex + 1 ) );
+ if ( recList != null )
+ {
+ // when /*/-pattern-string is found, add method
+ // list to universalList.
+ // Digester will do the rest
+ universalList.addAll( recList );
+ }
+ else
+ {
+ // if not, shorten tempParent to move /*/ one position
+ // to the left.
+ // as last part of patttern is always added
+ // we make sure pattern is allowed anywhere.
+ tempParentPattern = parentPattern.substring( 0, parentLastIndex );
+ }
+ }
+
// Universal all wildards ('!*')
// These are always matched so always add them
List<Rule> tempList = this.cache.get( "!*" );