You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by ying lcs <yi...@gmail.com> on 2007/08/10 17:44:10 UTC

Using Digester to set static variable

Hi,

I have a class like this:

public class Constants {
   public static int  parameter =  1;
}

How can i use digester rule to set the value of parameter of Constants?

Thank you.

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


Re: Using Digester to set static variable

Posted by simon <si...@chello.at>.
On Fri, 2007-08-10 at 10:44 -0500, ying lcs wrote:
> Hi,
> 
> I have a class like this:
> 
> public class Constants {
>    public static int  parameter =  1;
> }
> 
> How can i use digester rule to set the value of parameter of Constants?

Write your own rule implementation, ie your own subclass of the abstract
Rule class.

Assuming you want to use an xml attribute to specify the new parameter
value, you'll just need to override the method:
  public void begin(ns, name, attrs)

If you want the new value to be in the body of an xml element, then
instead override
  public void body(ns, name, text)

Regards,

Simon



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