XStream
XStream is a Java library to serialize objects to XML and back again.
NOTE: Not to confuse with at Meta.
XStream library
XStream uses reflection to discover the structure of the object graph to serialize at run time, and doesn't require modifications to objects. It can serialize internal fields, including private and final, and supports non-public and inner classes.Object graph serialization
When serializing an object it serializes the full object graph. Duplicate references encountered in the object-model will be maintained. For example, using the following class CDpackage com.thoughtworks.xstream;
public class Cd
and add some of these object to a list
Cd bj = new Cd;
Cd mr = new Cd;
List
order.add;
// adds the same cd twice
order.add;
order.add;
// adds itself
order.add;
XStream xstream = new XStream;
xstream.alias;
System.out.println;
If the above code is executed with XStream's default relative references mode, it will generate the following XML:
XStream is free software, distributed under a permissive, revised BSD-style licence.