Skip to main content

Adapting (@XmlJavaTypeAdapter) to a List without wrapping

1 reply [Last post]
rfogarty
Offline
Joined: 2008-03-04
Points: 0

Hi,

I have an object (let's call it LazyFoos) that I would like to map to a List or ArrayList using an XmlAdapter. E.g.

@XmlType(name="foo")
class Foo {
// whatever...
}

class FooAdapter implements XmlAdapter,LazyFoos> {
ArrayList marshall(LazyFoos foos) { ... }
LazyFoos unmarshall(ArrayList foos) { ... }
}

@XmlType(name="foosContainer")
class FoosContainer {
@XmlJavaTypeAdapter(FooAdapter.class)
@XmlElement(name="foo")
private LazyFoos foos;

// ...
}

My intent, is to have the owning object of LazyFoos (FoosContainer) to be able to write out Foo(s) without a wrapper. So using XmlAdapter to just adapt to another class that contains a List is not an option - that works but doesn't meet our spec.

The above, compiles and runs but no Foos are printed. Instead I get something like:

Thanks,
Ryan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
holzfreiweiss
Offline
Joined: 2007-09-27
Points: 0

Hello,

i'm interested in exactly the same...
So if anybody found a nice solution, please give some hints.

Thx in advance!
Thomas