I have been using XMLEncoder
to transform POJOs into XML and back again. Apart from storing POJOs, some XML output will also be used by other applications to generate other forms of data, such as reports.
So far this has worked well. Even as the POJOs evolve there have been no problems.
Recently I realised that not all values are actually output. Properties whose default values have not been altered will not be written. This is a problem for me.
From the Javadoc:
"The XMLEncoder class uses a redundancy elimination algorithm internally so that the default values of a Bean's properties are not written to the stream"
For me, it is important that the bean is output in its' entirety - including all default values.
Is there any way to disable this feature of XMLEncoder
?
I gave up on XMLEncoder and switched to XStream (see http://x-stream.github.io/).
Works well so far...