logo       

[xstream-dev] Support for 'default' collections.: msg#00000

java.xstream.devel

Subject: [xstream-dev] Support for 'default' collections.

Okay, I've now added basic support for default collections. A default collection is a special collection associated with a class that will have contain any item that does not map to another field.

Here's an example to make it a bit clearer....

class Person {
String name;
List toys;
}

xstream.addDefaultCollection(Person.class, "toys");

<person>
<name>Joe</name>
<computer>
<type>apple</type>
</computer>
<car>
<type>blue</type>
</car>
</person>

The <name> collection maps to a field in Person, however the other items <computer> and <car> don't, so they get added to the 'toys' collection.

Anyone interested in using this, please test it out, so I can iron out bugs and edge cases. Sending me bug-reports, failing unit-tests, documentation of how to use it or naming suggestions will be appreciated :).

Grab latest snapshot: http://dist.codehaus.org/xstream/jars/xstream-SNAPSHOT.jar

-Joe



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise