commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [betwixt] Object and Array handling
Date Tue, 15 Apr 2003 22:01:55 GMT
hi brian

On Friday, April 11, 2003, at 04:10 AM, Brian K. Wallace wrote:

>   When using Betwixt (and I'm not sure if the issue is completely with 
> Betwixt or
> shared with Digester) to write Objects or arrays of Objects I've found 
> two issues
> apart from the 'how to create an object that doesn't have an empty 
> constructor' issue.

this one is a thinking problem.

betwixt works with beans using reflection and this typically means that 
empty constructors are required. digester allows factory constructors to 
be registered and maybe betwixt could add something similar.

support should probably be added for mapping non-beans to strings and back 
again using ConvertUtils and i'll probably take a look at this when i get 
the chance. i don't know if this would be of any help.

>   1.  If an array of an object is passed in to the BeanWriter's write 
> method, the
> resulting XML isn't valid (the root object ends with a semicolon). e.g., 
> a String[]
> passed to the write method writes the String objects properly, but 
> enclosed in a
> <String;> element - which causes a SAXParseException (whitespace required 
> before
> attribute).

this is a betwixt bug. i've just committed a fix for this.

>   2.  If a method in a bean takes a java.lang.Object as a parameter, the 
> XML written
> out by the BeanWriter writes the object correctly (although it should 
> probably encase
> the written object in an element of the object's correct type),

i'm not sure about this. betwixt isn't really concerned with serialization 
but with automating common mapping use cases. i'd be happier to think 
about adding a setting that allowed classname to be written as an 
attribute rather than as an element. i don't know if that would be any use 
to you.

> but the BeanReader
> does not create an object of the orginal type to pass to the set method. 
> What is put
> into the bean after a read is an actual java.lang.Object.

betwixt guesses the type of object to create by examining the type of the 
parameter. so, if the method takes an object, this is what will be created.
  one way that this could be partially address is by adding a attribute in 
the betwixt file that allows the concrete class to be created to be 
specified. (this is needed to support interfaces.) i'm not sure whether 
this would be of any use to you.

- robert


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message