commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Madisetti, Sumesh " <sumesh.madise...@citi.com>
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 [mailto:jigsaw9876@yahoo.com] 
Sent: Thursday, October 04, 2007 5:02 AM
To: user@commons.apache.org
Subject: Digester: Adding object elements to an object

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.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message