Hi Xandrios,

Xandrios wrote:

> Hi Jörg, thanks so much for your response.
> 
> I was hoping to avoid writing custom converters but I'm starting to
> think I will need to indeed. Your example gave me another idea though:
> 
> If I can read all elements (volvo, chevy, policeCar and Officers) into
> one generic (ordered!) list (of type <Object>) I can simply
> post-process the list. When sequentially reading all entries I can
> match the officers to a policeCar.

That was the idea.

> When I tried this in my project I found that the bindings are not that
> easy to accomplish this. The list (of type <Object>) does not get any
> elements added to it. So obviously xstream does not realize that it
> should expect these elements there and put them all into the generic
> list.

class Container {
@XStreamImplicit();
private List<Object> items;
}

This should simply work. Without knowing what else you're configuring and 
how your data structure looks like, I can also look into a crystal ball for 
advice ;-)

> The way I tried to fix this is to typecast the list as <Element>
> instead of <Object>. In the Element.class I then added the
> @XStreamInclude annotation to let xstream know all instances of volvo,
> chevy, policar and officer should be included. (these objects extend
> Element.class). Unfortunately this did not work either.

Sorry, here I'm lost. This does not make sense to me.
 
> Any tips on how to get the mapping for these elements right and put
> them into a generic <Object> list?

Provide data structure and XStream initialization. Oh, and it does make much 
more sense to write the objects first. When the generated XML matches, you 
can normally also read it. Trying it the other way round is a *very* 
annoying process.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to