commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [BETWIXT] Array of bytes anyone?
Date Tue, 13 Jul 2004 22:09:02 GMT
On 13 Jul 2004, at 16:51, Henning P. Schmiedehausen wrote:

> Hi,

hi henning

> for a project, I need Betwixt to convert a special sort of beans into
> XML. Beans, which contain a byte [] property (They come from Hibernate
> which maps BINARY and TEXT onto these types, which is fine).
> Regular Betwixt builds something like
> <foo>
>   <byte>0</byte>
>   <byte>1</byte>
>   <byte>2</byte>
>   <byte>3</byte>
> </foo>
> for propery foo, which is not exactly the most efficient way to
> express this array of bytes. Especially if it has about 5 MBytes
> size. ;-)


> I was wondering whether I could get this done with regular betwixt but
> the isPrimitive() in XMLIntrospectorHelp always bite me.

XMLIntrospectorHelper is very limiting and will hopefully be completely  
deprecated sometime soon. the primitives concept needs to be extended  
into the more flexible concept of simple type. (the simple type concept  
is more often used in the xml-object binding community.) the refactored  
code with improved design has been merged into HEAD now and some of  
these changes in this direction have been made (but i've lost track a  
bit since i'm currently juggling a number of releases at the moment).  
just FYI the plan is to cut a 1.6 based on the improved design very  

> In the end I came up with the attached patch, which works fine for me  
> (it might not
> be ideal, because the resulting XML contains the raw sew^Wbinary data
> if you write the bean out.

i'm not sure i parse this correctly. (it's a little late, so it might  
be me.) care to expand?

> For my application I extend the DefaultObjectStringConverter to do
> base64 encoding on the fly and end up with nice looking XML like this:
> <foo attr1="1" attr2="2" attr3="3">
>   <binary>
> xCHPdC7mAlirPoYY8dZr1fACaXAqpW83BKOz// 
> yCMWUkzgtkvkMhD0MwQpclKdsOhHB1PbaRzbxA
> 5KmsIprAxtG5Vkm2ze5jRUPY+og3Rqq5ccj19BL6joB0PKQmnJRlU0bw9ZGJntrIVH4g9Lq 
> 1E4Sx
> bquW8iIOBGvsE3kYaW0bbf1mdPT2ubNnW2+fbm17wnhQxw9Ertbz1M69Mdp649/TZ// 
> 64WVw6Gg5
> aLwq2161CMeKB0glbtMXxpNGASDG4G42q16YDtOIbJwRF429GLfpc+OJAI7UkHhGvx+cDcH 
> YoSnsRNN+jn9AfcogqRDz/ 
> L1cSbZxSgQAAAABJRU5ErkJggg==
>   </binary>
> </foo>
> which is exactly what I need.
> I was wondering if it would be more clever to allow the user to
> explicitly set the primitiveType property of the element descriptor
> from the .betwixt file. I found no way to do so, though and I already
> had this patch which works for me.

the answer is yes but the concept needs to move from a fixed list of  
primitives to a flexible, configurable (with strategy plugin as well as  
property) simple type binding. this is definitely on the to-do list but  
i'm right in the middle of managing various release cycles so i'm not  
sure when i'll get the chance to look at this.

it should be pretty straightforward and i'd be willing to help explain  
the new design, so if you'd like to volunteer to take this on, that  
would be great.

> Anyway, here is the patch, discussions welcome. ;-) This is against
> CVS HEAD. I would volunteer to write an Unit test for it if has a
> chance to get applied.

there is every chance that a fix for this would get committed with a  
unit test :)

i have an idea that the patch is against the 0.5 code base (but i could  
be wrong since i haven't looked into this in detail). please set my  
suspicious mind at rest by updating before you start getting into this.

- robert

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

View raw message