commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: how to add an object to a map by using a XML config file?
Date Sat, 05 Feb 2005 03:31:14 GMT
Hi Martin,

On Fri, 2005-02-04 at 15:57 -0300, Gorostegui Martin (SFN) wrote:
> Hi,
> In the application i´m working on, we are currently setting the Digester
> rules from a class and adding the resulting objects to a list and,
> sometimes, to a hashmap. We do this by calling an "add" method from a
> CallMethod rule. 
> Now we are trying to change the implementation and set the Digester rules
> from an xml config file. Adding the object to the list is not a problem as
> we can achieve this by pushing the list to the stack for making it the root
> item and then use the SetRoot rule for calling the list´s add method passing
> the top object as parameter. But we can´t find a way for adding and object
> to a hashmap, as we need to pass the top object and the key as parameters.
> The SetRoot rule can´t be used here because it doesn´t accept other
> parameter than the stack´s top object. 
> I´ve found ways of doing this by using a supporting class for the cases in
> which I need to use the hashmap, but my idea is to use only an xml config
> file per case.
> Basically what I need is a SetRoot rule accepting parameters like the
> CallMethod rule.
> Anybody knows a solution to this problem or if what I mentioned will be
> considered for future releases? 

Well, the CallMethodRule class has an optional "target stack offset"
that can be used to point to any object on the digester's object stack
rather than just the top object. Specifying "-1" will cause methods to
be invoked on the root object of the stack.

This functionality is currently accessable only when using the api (ie
not when using xmlrules). If you wish to use this from xmlrules, please
feel free to implement the missing bits in DigesterRuleParser (probably
about 3 lines) and submit a patch!



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

View raw message