Details
-
Type: New Feature
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 1.1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
In order to keep the XML small, it would be nice to ignore fields for which the default values are not changed, similar to the way it is done in the XMLEncoder:
Eg:
public class MyClass {
private int m_value = 2;
public int getValue()
{ return m_value; }public void setValue(int value)
{ m_value = value; } public MyClass() {
}
}
Serializing a new instance of this class, without changing the value gives following output:
//XStream
<com.alcatel.ni.commands.core.MyClass>
<m_value>2</m_value>
</com.alcatel.ni.commands.core.MyClass>
//XMLEncoder:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2" class="java.beans.XMLDecoder">
<object class="com.alcatel.ni.commands.core.MyClass"/>
</java>
I'd like this to be configurable, with the default being all properties serialized. I can see situations where both options would be desirable.
Also, if you serialize an object, change the object code (and default values), then de-serialize, you'll possibly have different behavior. Just something to be aware of. Again, I could see uses for this...