commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Madisetti, Sumesh " <>
Subject RE: Digester: Adding object elements to an object
Date Thu, 04 Oct 2007 12:06:33 GMT
Once an entry processing is finished, you need to add call -
digester.addSetNext("map/entry", "addEntry");

-----Original Message-----
From: J S [] 
Sent: Thursday, October 04, 2007 5:02 AM
Subject: Digester: Adding object elements to an object


I have (partof) an  XML similar to this from Digester FAQ

  <entry key='key1'>value1</entry>
  <entry key='key2'>value2</entry>
  <entry key='key3'>value3</entry>
  <entry key='key4'>value4</entry>
 My 'Mymap' class:
public class Mymap {
    private List<Entry> entries;
    public void setEntries(List<Entry> entries) {...}
    public void addEntry(Entry entry) { ... } } Entry class public class
Entry {
    private String key;
    private String value;

While I am able to follow the FAQ and add an Entry object to a HashMap,
I am stumped when tryign t oadd an Entry object to a Mymap object. My
digester piece of code:
digester.addObjectCreate("map", Mymap.class);
digester.addObjectCreate("map/entry", Entry.class);
digester.addSetProperties("map/entry", "key", "key")
digester.addCallMethod("map/entry", "setValue", 1);
digester.addCallParam("map/entry", 0); Rule r = new CallMethodRule(1,
"addEntry", 1); digester.addRule("map/entry", r);
digester.addCallParam("map/entry", 0, true);

Can anyone help, please??


Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo!

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

View raw message