commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [digester] how to use digester with a class hierarchy
Date Wed, 19 May 2004 02:38:55 GMT
On Wed, 2004-05-19 at 14:26, Bill Keese wrote:
> I'm curious how people use digester to persist class hierachies.
> Consider the class hiearchy below (that represent graphical objects).
> class Component { int x,y; }
> class TextString extends Component { String text; }
> class Rectangle extends Component { int width, height; }
> There are two ways represent a TextString in XML:
> <textString><x>10</x><y>20</y><text>Hello world</text></textString>
> <Component><x>10</x><y>20</y><textString>Hello
> world</textString></Component>
> Which is better? I would guess that the first version is more common,
> but the second version allows simple searches of all components based on
> their x/y coordinates.
> Can digester digest the second version?

Hi Bill,

Interesting question!

As far as I can see, there is no way for Digester to process the second
form you suggest. All the existing Digester object creation options
(ObjectCreateRule, FactoryCreateRule) create the target object when the
opening xml tag is found. But the layout you suggest essentially
requires the whole tag to be processed before the object is created;
only when the <textString> tag is found do you know what object type to

I imagine that supporting the second syntax is not easily done with an
event-based parsing system such as SAX. 



It is therefore not currentlypossible

> Thanks,
> Bill
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message