commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <lshan...@futurebrand.com>
Subject Re: Need a little help
Date Tue, 01 Feb 2005 20:40:33 GMT
Success! Thanks Wendy.

This is what worked, outside of a few small changes syntax changes, your
thinking is exactly correct.

public TreeMap digest() throws IOException, SAXException {
  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 (TreeMap)digester.parse(parseMe);

 }

Luke


----- Original Message ----- 
From: "Wendy Smoak" <java@wendysmoak.com>
To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Tuesday, February 01, 2005 3:19 PM
Subject: Re: Need a little help


> 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
>



---------------------------------------------------------------------
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