commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessio Pace <alessio.p...@gmail.com>
Subject [Digester] How make digester call setStringArray(String[]) from single element node content?
Date Mon, 02 Jan 2006 17:27:01 GMT
Hi,

imagine I have a class with some simple set methods (setField(String) ,
setOtherField(int) )  and then a more "complicated" setter method like this:

public void setStringArray(String[] stringArray){
    this.stringArray = stringArray;
}


Now imagine I would like to read my class from XML using digester, and the
format is like:

<myclass>
    <field>string</field>
    <otherField>100</otherField>
   <stringArray>A, B, C</stringArray>
</myclass>

Is there any default syntactic sugar that makes me accomplish this task
without having to write a custom converter or rule (sorry if I don't use the
correct Digester terms, I am almost a newbie) to make digester call
setStringArray( {"A", "B", "C"} )  ??

Using:
   digester.addBeanPropertySetter("root/someother/stuff/class/?");

I have succesfully solved the issue about setField(String)  and
setOtherField(int), but I am not able to get the array setter to be properly
called.

If the design of the approach is inherently ugly, suggestions are welcome
for an alternative XML format (and relative Digester rule) to store an and
retrieve an array of strings :)

Thanks in advance.

--
Alessio Pace.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message