users@jaxb.java.net

Re: Unmarshalling to an existing object?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 5 Feb 2008 07:27:49 +0100

Hi.

> In my app I have a JAXB generated binding object instance. The instance
> may be modified via "edit" actions. The modifications may be saved via
> "save" action or discarded via "discard" action. I am looking for some
> way to restore the original state of the JAXB generated binding object
> from a snapshot of its original state. What would be terrific is if
> there was some way to unmarshal previously marshalled state to an
> existing object instance. This would allow me to restore the state on
> discard.
>
> Is there any way to do this? If not, how have others solved similar
> design issue? TIA for your help.

Take a look at "copyable" plugin from jaxb2-commons. You can
unmarshall an object an copy its state into another object. You may
also provide an own "copy builder" which could, for instance, resolve
conflicts while copying.

Bye.
/lexi