commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishore Senji <>
Subject Re: Need a little help
Date Tue, 01 Feb 2005 00:18:03 GMT
> public Version digest() throws IOException, SAXException {
>  digester = new Digester();
>  digester.setValidating(false);
>  digester.addObjectCreate("DATA/VERSION", Version.class);
>  digester.addObjectCreate("DATA/VERSION/ITEM", Item.class);
>  digester.addSetProperties("DATA/VERSION/ITEM", "name", "name");

The above line should be 
digester.addSetProperties("DATA/VERSION/ITEM", "NAME", "name"); Since
the NAME attribute is in capitals, where as the "name" property on
Item is in small letters

>  digester.addCallMethod("DATA/VERSION/ITEM", "setContents");

Digester is not able to find setContents because the above tells
digester to look for a method called setContents which takes no
arguments. But the setContents on Item takes a String. Since you are
looking to get the body content and set it to the contents of the
Item, use

digester.addCallMethod("DATA/VERSION/ITEM", "setContents", 0);

You might also want to add the Item to the Version's map I believe.
Since I don't see that call here, I would add it here

digester.addSetNext("DATA/VERSION/ITEM", "addItem");

Where "addItem" method will live on the Version class which takes an
Item as an argument and add it to the TreeMap with the "name" of the
"Item" as the key

>  return (Version)digester.parse(parseMe);
> }

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

View raw message