commons-user mailing list archives

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

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! Games.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message