commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J S <jigsaw9...@yahoo.com>
Subject Digester: Adding object elements to an object
Date Thu, 04 Oct 2007 09:02:07 GMT
Hi,

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

<map>
  <entry key='key1'>value1</entry>
  <entry key='key2'>value2</entry>
  <entry key='key3'>value3</entry>
  <entry key='key4'>value4</entry>
</map>
 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??

TIA,
JS

       
---------------------------------
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message