commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [Digester] Please help....
Date Thu, 19 Jun 2003 18:05:24 GMT

lots a differnet ways you could do it... I would suggest creating 2

1. OrderCollection
2. Order

then get some Digester Rules like this....

Digester digester = new Digester();
OrderCollection ordercollection = new OrderCollection();

//lets push the instance of ordercollection before we parse anything

//now lets add some rules to the digester instance.

//when we come across an <order> tag lets create a new instance of the
order class
digester.addObjectCreate("/order", "Order", "ClassName");

//now that the order class is the top most class instance on the stack lets
match some order
//attributes to some methods on the order for example, something
like this.

//we come across the <order><account> pattern lets call the setAccountID
method in our order class
digester.addCallMethod("/order/account", "setAccountID", 0);  // 0 meaning
no additional params for this method

//same thing for symbol lets call a method to set that when we come across
digester.addCallMethod("/order/symbol/", "setSymbol", 0);

//then when we come across the </order> tag, lets pop the order class
instance and add that to the order collection class

//this will take the entire order instance, call a method on the order
collection and pass the order object as a param to that
digester.addSetNext("/order", "addOrder");

//now lets parse the xml file and get an instance of the ordercollection we
pushed onto the stack

OrderCollection populatedcollection = (OrderCollection)

Hope that helps!
- Duncan

This transmission may contain information that is privileged, confidential and/or exempt from
disclosure under applicable law. If you are not the intended recipient, you are hereby notified
that any disclosure, copying, distribution, or use of the information contained herein (including
any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error,
please immediately contact the sender and destroy the material in its entirety, whether in
electronic or hard copy format. Thank you.

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

View raw message