commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel S. Tarkenton" <d...@tarksoft.com>
Subject Re: [digester] Need to create custom Rule?
Date Thu, 09 Jun 2005 21:03:22 GMT

> Roughly, you need this:
>
> class MyChildHandlerRule extends Rule {
>   public void begin(ns, elementName, attrs) {
>     String nameAttr = attrs.get("name");
>     if (nameAttr != 'theParamDesired')
>       return;
>
>     MyValueHolder obj = (MyValueHolder) digester.peek();
>     String valueAttr = attrs.getValue("value");
>     obj.setValue(valueAttr);
>   }
> }
>
> digester.addRule("parent/child", new MyChildHandlerRule());
>
> The SetPropertyRule does something similar to what you describe, but not
> exactly. You might want to have a look at the code for this rule. But
> being a "generic" rule, it can't make some of the simplifying
> assumptions that the above custom Rule class can.
>
> By the way, when posting to commons-user, please put the component name
> in the subject line (as I have done in this reply).
>
> Regards,
>
> Simon
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: commons-user-help@jakarta.apache.org

Sweet!  That custom Rule worked great and was very, very simple.  Thanks
for the tip.  My parser seems to be working again.

Oh, and apologies for omitting the particular commons resource my question
related to in the subject -- won't forget next time ;)

/Dan




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


Mime
View raw message