commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertdon...@mac.com>
Subject Re: [PATCH] [DIGESTER] tail-match pattern on root node
Date Wed, 10 Jul 2002 18:14:08 GMT
this patch has now been applied.

many thanks.

- robert

On Wednesday, July 10, 2002, at 12:43 PM, Mike Flester wrote:

> Hi --
>
> The patch submitted (by me) doesn't work right.
> It causes the "*/a" pattern to match <aaa> among
> other things.
>
> Here is the better fix. This is a replacement for
> my last submitted patch which fixes the problem
> mentioned above and adds another test.
>
> Thanks,
> Mike
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
> Index: jakarta-
> commons/digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-
> commons/digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java,
> v
> retrieving revision 1.2
> diff -u -r1.2 ExtendedBaseRules.java
> --- jakarta-
> commons/digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java	
> 9 Jan 2002 20:22:49 -0000	1.2
> +++ jakarta-
> commons/digester/src/java/org/apache/commons/digester/ExtendedBaseRules.java	
> 10 Jul 2002 11:38:24 -0000
> @@ -405,7 +405,8 @@
>       * Matches the end of the pattern to the key.
>       */
>      private boolean basicMatch(String key, String pattern) {
> -        return pattern.endsWith(key.substring(1));
> +        return (pattern.equals(key.substring(2)) ||
> +                pattern.endsWith(key.substring(1)));
>      }
>
>  }
> Index: jakarta-
> commons/digester/src/java/org/apache/commons/digester/RulesBase.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-
> commons/digester/src/java/org/apache/commons/digester/RulesBase.java,v
> retrieving revision 1.7
> diff -u -r1.7 RulesBase.java
> --- jakarta-
> commons/digester/src/java/org/apache/commons/digester/RulesBase.java	9 Jan 
> 2002 20:22:49 -0000	1.7
> +++ jakarta-
> commons/digester/src/java/org/apache/commons/digester/RulesBase.java	10 Jul 
> 2002 11:38:25 -0000
> @@ -252,7 +252,8 @@
>              while (keys.hasNext()) {
>                  String key = (String) keys.next();
>                  if (key.startsWith("*/")) {
> -                    if (pattern.endsWith(key.substring(1))) {
> +                    if (pattern.equals(key.substring(2)) ||
> +                        pattern.endsWith(key.substring(1))) {
>                          if (key.length() > longKey.length()) {
>                              // rulesList = (List) this.cache.get(key);
>                              rulesList = lookup(namespaceURI, key);
> Index: jakarta-
> commons/digester/src/test/org/apache/commons/digester/RulesBaseTestCase.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-
> commons/digester/src/test/org/apache/commons/digester/RulesBaseTestCase.java,
> v
> retrieving revision 1.5
> diff -u -r1.5 RulesBaseTestCase.java
> --- jakarta-
> commons/digester/src/test/org/apache/commons/digester/RulesBaseTestCase.java	
> 23 Mar 2002 17:45:59 -0000	1.5
> +++ jakarta-
> commons/digester/src/test/org/apache/commons/digester/RulesBaseTestCase.java	
> 10 Jul 2002 11:38:27 -0000
> @@ -228,6 +228,16 @@
>                  "*/c/d",
>                  ((TestRule) digester.getRules().match(null, 
> "x/c/d").iterator().next()).getIdentifier());
>
> +        // Test wildcard tail matching at the top level,
> +        // i.e. the wildcard is nothing
> +        digester.addRule("*/a", new TestRule("*/a"));
> +        assertEquals("Wildcard tail matching rule 3",
> +                     1,
> +                     digester.getRules().match(null,"a").size());
> +
> +        assertEquals("Wildcard tail matching rule 3 (match too much)",
> +                     0,
> +                     digester.getRules().match(null,"aa").size());
>          // clean up
>          digester.getRules().clear();
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.
> org>


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


Mime
View raw message