commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simon <>
Subject Re: [Digester] Generic digester patterns?
Date Thu, 02 Aug 2007 20:25:28 GMT
Hi Ernst,

On Thu, 2007-08-02 at 18:54 +0200, Ernst de Haan wrote:
> Simon,
> > As noted in the javadoc it only supports "primitive" nested  
> > properties.
> > Once a SetNestedPropertiesRule matches, no other rules fire beneath  
> > it.
> >
> > So in your case, rather than using SetNestedPropertiesRule you'll need
> > explicit rules to handle Config/background and Config/axisColor.
> OK, too bad. I've started converting it to explicit rules and that  
> works OK.
> Any chance the approach I was taking will be supported in a future  
> Digester release? It makes my configuration smaller, less error-prone  
> and much easier to read and comprehend.

The problem is really that the default rule-matching engine does not
support trailing-wildcard patterns.

Digester can support different rule-matching implementations, and in
fact a couple are included with Digester.

Interface Rules defines the required API.

Class RulesBase is the default implementation. This supports
leading-wildcard patterns, but not trailing-wildcard patterns. The
SetNestedPropertiesRule resorts to some tricks to implement a limited
kind of "trailing wildcard" handling, ie if pattern "foo/bar" is mapped
to a SetNestedPropertiesRule then that same rule can also effectively
handle "foo/bar/*". However the side-effect of the trick used is to
disable all other rules temporarily.

Class ExtendedBaseRules allows trailing-wildcards. See the javadoc for
this class for details. With trailing-wildcard support, you don't need
SetNestedPropertiesRule as the SetPropertyRule will do fine. However
there are drawbacks to using the ExtendedBaseRules class, including
performance and some complexity. I don't use the xmlrules module so
don't know how you use a non-default Rules implementation with it.

Class RegexRules is another implementation that uses standard regex
rules for patterns.

So in summary, if you're really keen to have a single rule match all
Config/* elements, then try using ExtendedBaseRules or RegexRules and
NOT SetNestedPropertiesRule.

Feel free to ask more questions if you have problems with this.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message