commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wendy Smoak" <j...@wendysmoak.com>
Subject Re: Need a little help
Date Tue, 01 Feb 2005 20:19:16 GMT
From: "Luke Shannon" <lshannon@futurebrand.com>

>  public TreeMap digest() throws IOException, SAXException {
>   digester = new Digester();
>   digester.setValidating(false);
>   digester.addObjectCreate("DATA/VERSION", "createTreeMap");

An ObjectCreateRule needs to know the type of object to create, not a method
to call.  You need to let Digester create an object and push it on the
stack, and calling createTreeMap won't do that.

>   digester.addSetProperties("DATA/VERSION/ITEM", "NAME", "name");
>   digester.addCallMethod("DATA/VERSION/ITEM", "addItem", 0);
>   return fieldsValues;
>  }

I thought...
   digester = new Digester();
   digester.setValidating(false);
   digester.addObjectCreate("DATA/VERSION", "TreeMap.class");
   digester.addCallMethod("DATA/VERSION/ITEM", "put", 2);
   digester.addCallParam("DATA/VERSION/ITEM", 0, "NAME");
   digester.addCallParam("DATA/VERSION/ITEM", 1);
   return digester.parse(file);

It should create a TreeMap and then call 'put' with the value of the NAME
attribute and the body of the <ITEM> tag as the name/value pair.  Some of
the method params may be switched around, double check the signatures.

HTH,
-- 
Wendy Smoak


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


Mime
View raw message