commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: Read XML with Betwixt
Date Wed, 07 Jun 2006 21:43:11 GMT
On Wed, 2006-06-07 at 10:50 +0200, Jean-Baptiste.Binet@alcatel.fr wrote:
> Hello,

hello jean

> I am new to Betwixt and I have the following problem.
> I have the following MyBean class :
> public class MyBean
> {
>         private String str;
>         private String[] arrayOfElement;
>  
>         public String getStr()
>         {
>                 return str;
>         }
> 
>         public void setStr(String str)
>         {
>                 this.str = str;
>         }
> 
>         public String[] getArrayOfElement()
>         {
>                 return arrayOfElement;
>         }
> 
>         public void setArrayOfElement(String[] arrayOfElement)
>         {
>                 this.arrayOfElement = arrayOfElement;
>         }
> }
> 
> You notice that there is not add method to add an element in 
> arrayOfElement attribute.
> It is because this bean is generated by another utility and I can not add 
> new methods.
> So this bean is not modifiable and only has these methods.
> 
> Now I have the following XML file that I want to read using Betwixt :
> <MyBean>
>         <str>toto</str>
>         <element>elt1</element>
>         <element>elt2</element>
> </MyBean>
> 
> So how can I manage the fact that there are many <element> tags but no add 
> method in MyBean class ?

quite possibly not easily, i suspect but it's worth giving it a go. if
you aren't using the latest code from trunk, please checkout the code
and build using maven (a lot of additional features have been added
since the last release) before you try the mapping.

i suspect that some additional support for the array in this use case
may be required. i'm unlikely to be able to look at this until early
next week.

if you can't wait that long, JiBX may perhaps be able to map it
http://jibx.sourceforge.net/tutorial/binding-tutorial.html. JiBX is a
mapper (like betwixt) but is generative and field based (rather than
dynamic and bean based). not sure how good the array support is for this
use case, though.

- robert



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


Mime
View raw message