basic unmarshall questions with nested collections

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

basic unmarshall questions with nested collections

saltamontes
This post has NOT been accepted by the mailing list yet.
all i want to do is unmarshall a simple xml file involving nested collections

<persons>
        <person><name>billy</name>
                <address>
                        <address1>West St.</address1>
                </address>
                <address>
                        <address1>East St.<address1>
                </address>
        </person>
        <person><name>bob</name>
                <address>
                        <address1>North St.</address1>
                </address>
                <address>
                        <address1>South St.<address1>
                 </address>
        </person>
</persons>


after finding that JAXB and Castor do not work w/ Spring Security i decided to give Xstream a try.
i have tried all the examples at codehaus.
i have googled countless sites.
the examples at codehaus are all marshall-centric.
no where is there a simple, complete example that does this most basic of requirements.

i have tried aliases, implicitCollections and annotations with limited success.
which is why i regrouped and am now seeking out a better basic understanding of xstream.



some questions:

custom converters:
- when are they used?
- how compare to the generic converters?
- examples of the generic converters being used?
- differences between java.lang and java.util for the generic converters?
- differences between ArrayConverter and NamedArrayConverter in generic converters? (for example)
- does one even need any converters for this example, or does xstream auto convert everything?

aliases:
- are these used to refer to <elementName> or the name of the class attribute?
- are they required when you already have "person" in: addImplicitCollection(Person.class, "person")?
- are they req. if the <name> matches private string name (class atrribute name)?

addImplicitCollection:
- whats the diff between the 3 diff addImplicitConversion() methods?
- addImplicitCollection(Person.class, "person"); i think this maps <person> to Person.class
- if yes, what does addImplicitCollection(Person.class, "person", Person.class); do?
- is addImplicitCollection() required for the outermost <persons></persons>?

collections:
- can i use sets? (all the examples are as Lists)
- is there a specific method signature i need to use when defining attribute in my classes?
- do i need ea class to have a complete constructor?
- POJO's use get(), set(), but examples have get(), add().. will get(), set() work?


are command objects required if there is not a model for the xml root?
ie, i have/need no "Persons" model, do i need one to map to root <persons>?

is there a required order of alias, addImplicitCollection, etc. in your code?

when should one use <addresses></addresses> as root element?
does this require an alias or addImplicitCollection() for <address> records?

whats a short definition of differences between "enhanced" and "regular" mode?
(beyond whats in the faq)



thx for the read, i have to assume that everyone starting w xstream have these same basic questions.