commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [betwixt] className for String, Integer?
Date Mon, 01 May 2006 22:28:05 GMT
On Mon, 2006-05-01 at 15:10 -0500, Michael Gardner wrote:
> Robert, thanks for the quick response. I submitted a bug to Bugzilla (
>, though without a
> unit test yet since I'm having trouble getting the Betwixt test harness
> working.

if you continue to have problems, check out the source from subversion
and take a look at the test cases in there. betwixt is mavenised
( so building is easy. if you use eclipse, maven
will generate a basic project outline. 

> Anyway, my basic use case involves properties that have setters with formal
> parameter type 'Object': if I try to write such a bean that happens to have
> a String as the value of such a property, BeanWriter will not write the
> className property even though I've un-suppressed the className property in
> general. Then when a BeanReader tries to reconstruct the object, it creates
> a plain Object instead of a String (this also happens with Integer, etc.).


> I can create wrappers for those types to work around the problem, but it
> really messes up my code -- especially since this issue affects more than
> one of my bean types. I thought of modifying Betwixt to no longer treat
> Strings, etc. as simple types, but would BeanWriter still know how to write
> them to XML in that case?

recognition of simple types is pluggable. you'd need to create custom
mappings for Integer and String but that should be ok.

read in again is actually more difficult due to the fact that Integer
and String are not really beans. i don't have the time to supply any
code samples right now but i'll try to set you on the right path...

if you have flexibility over the xml format then the quickest and
easiest way to make things work would be to output the value of the
string or integer as an attribute. then use a new custom
BeanCreationChain which knows how to create a string or integer with the
correct value when called upon to create the object from the complex

otherwise, you need to looking into creating a custom MappingAction
which is more difficult.

- robert

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

View raw message