I want to serialize with XMLEncoder classes that are generated by wsimport tool. There are many ArrayOfXXXXXX classes that have the following structure:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfSitejournal", propOrder = {
"item"
})
public class ArrayOfSitejournal
implements Serializable
{
protected List<Journal> item;
public List<Journal> getItem() {
if (item == null) {
item = new ArrayList<Journal>();
}
return this.item;
}
}
When I serialize ArrayOfSitejournal class I get this output:
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.7.0_45" class="java.beans.XMLDecoder">
<object class="ArrayOfSitejournal"/>
</java>
There is no setItem() method so item property is not serialized. My question is: how I can serialize whole ArrayOfSitejournal object together with item member?
I can't change code of this class because it is generated.
I know that I can write PersistenceDelegate to customize serialization. But to deserialize it invocation like this is necessary:
arrayOfSitejournal.getItem().add(journal)
Can you please help me to write such PersistenceDelegate.