commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [Betwixt] Composite properties
Date Sat, 15 Mar 2003 13:41:16 GMT
On Friday, March 14, 2003, at 12:49 PM, Maksimenko Alexander wrote:

> 1. How can I define wrapCollectionsInElement  for particular composite 
> property of the bean. Or in general, how can i access ElementDescriptor 
> for particular bean.

i'm a little unclear about exactly what you're asking here.

are you asking how you can set wrapCollectionsInElement for a particular 
property (rather than globally for every property)?

the answer is - at the moment, there is no way. on the other hand, it is 
on the to do list and i'd be willing to take a stab at an implementation 
if you need it. i'd probably an element attribute whose presence would 
override the writer setting when that element is written.

as for the second question, you can totally replace the betwixt 
introspection system by plugging an custom XMLBeanInfoRegistry. just 
create your own class extending XMLBeanInfo which contains a description 
of you bean. then create a XMLBeanInfoRegistry which contains supplies an 
instance whenever the class is requested.

another item on the to do list is a XMLBeanInfoRegistry which would have a 
protected set of XMLBeanInfo implementations to make this kind of thing 
much easier. i might bring this forward if you plan to go down this route.

> 2. Suppose i have
> class A
> ..
> Map getFooMap()
> void addFoo(B foo)
> Can i map A into
> <a>
> <foo name="name1" value="value1"/>
> <foo name="name2" value="value2"/>
> <foo name="name3" value="value3"/>
> </a>
> not in
> <a>
> <entry>
>     <key>name1</key>
>     <value>value1</value>
>  </entry>
> ....
> </a>

(at the moment) betwixt always outputs map entries using the following 


where xxx is the betwixt mapping of the key object and yyy the mapping of 
the value object.

i can see that:

<foo name="name1" value="value1"/>
<foo name="name2" value="value2"/>
<foo name="name3" value="value3"/>

would be a common pattern for String valued maps. if this is the case for 
you, then i might be able to come up with a way to quickly add this 
feature to betwixt.

it might be more difficult for object values maps since you'll need 
appropriate object->value conversion. it would make round tripping complex 
since you'd need a string -> object factory. it's not impossible but it'd 
need some thinking about. i'd be interested to hear other people views on 

- robert

View raw message