commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Siddharth Mathur" <smat...@nellymoser.com>
Subject [Digester] Converting String value of an attribute to array of integers
Date Fri, 17 Feb 2006 23:23:37 GMT
Dear all,

I am trying to use Digester to read my own XML format (shown below) and
convert it to correctly initialized objects. 

<List>

<A ID="1" author="Home made">
	<range>90</range>
</A>

<B ID="2" author="Apple Inc." depends="1">
	<bitrate>90</range>
</B>

[...more entries here]

<C ID="7" author="CT" depends="4,6">
	<flavour>AAC</range>
</C>

</List>


Classes A, B, C are all derived from a parent class which has three
properties:
i) ID (integer)
ii) author (String)
iii) depends (array of IDs i.e integers)

Digester makes it very easy to create setter and getter methods and read in
(i) and (ii) above. But how do I modify the default Rule so that the String
value of the "depends" attribute is converted to an array of integers
property? I will be happy to reformat the depends="4,6" part if required. 

I currently use d.addSetProperties("List/A") to read in my other attributes.


Thank you for your time and patience,
Siddharth


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