DataHolder

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

DataHolder

uwe schaefer
Hi

i am trying to use the DataHolder interface to record information on
marshalling and add info on unmarshalling using a custom converter.

while this works if i use XStream.marshall/unmarshall methods, i get
NPEs if i use fromXML/toXML on the same xstream instance.

i *thought* (that might be my misconception) that newDataHolder() was
called during toXML to create an initial DataHolder to be passed to the
converters.

according to my eclipse and my debug-output, XStream.newDataHolder is
never called.
Am i right and this is a bug, or what do i miss ?

is there another way of getting grips of the DataHolder being used on
unmarshalling, so that i can provider the info to it which is needed by
my converter?

XStream version is 1.4.5/6

cu uwe

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DataHolder

Jörg Schaible-2
Hi Uwe,

[hidden email] wrote:

> Hi
>
> i am trying to use the DataHolder interface to record information on
> marshalling and add info on unmarshalling using a custom converter.
>
> while this works if i use XStream.marshall/unmarshall methods, i get
> NPEs if i use fromXML/toXML on the same xstream instance.
>
> i *thought* (that might be my misconception) that newDataHolder() was
> called during toXML to create an initial DataHolder to be passed to the
> converters.
>
> according to my eclipse and my debug-output, XStream.newDataHolder is
> never called.
> Am i right and this is a bug, or what do i miss ?
>
> is there another way of getting grips of the DataHolder being used on
> unmarshalling, so that i can provider the info to it which is needed by
> my converter?
>
> XStream version is 1.4.5/6

I am not sure, what you really want to do. The DataHolder that is used by
default is created for every call to marshal/unmarshal so that the
converters may communicate within one (un)marshalling process.

If you provide a DataHolder yourself, you define how long this data is kept.

XStream.newDataHolder is a convenience method for *you* to provide an own
one, XStream does not call it.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DataHolder

uwe schaefer
On 01/18/2014 06:36 PM, Jörg Schaible wrote:

Hi Jörg,

thanks for taking the time.
> I am not sure, what you really want to do. The DataHolder that is used
> by default is created for every call to marshal/unmarshal so that the
> converters may communicate within one (un)marshalling process.

here's what i intend to do:

while marshalling my root object i record some information that is not
to be written into the xstream writer.

while unmarshalling, i'd like to pass this recorded information into the
unmarshalling process, so that my converter (that previously had
collected the information) can now reconstruct the full object state
that is more than what can be found in the reader.

my usecase is something like:
- marshalling an object to xml and excluding blob data.
- moving detached blob-data and marshalled object over the wire
- unmarshalling and re-attaching the blob data.

it works nicely with calling mashall/unmarshall myself, providing a
custom DataHolder.
the only inconvenience is, that - calling unmarshall - i need to know
what the root-type is. not that much of a problem, i'd just wanted to
mention it.

my misconception was newDataHolder being a factory method that provides
a hook to tweak the object used by xstream.

thanks, uwe

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DataHolder

uwe schaefer
On 01/18/2014 06:51 PM, [hidden email] wrote:
> it works nicely with calling mashall/unmarshall myself, providing a
> custom DataHolder. the only inconvenience is, that - calling
> unmarshall - i need to know what the root-type is.
PS: i just realized i could just pass null as the root object, so the
above statement is plain wrong.

sorry, uwe

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: DataHolder

Jörg Schaible-2
Hi Uwe,

[hidden email] wrote:

> On 01/18/2014 06:51 PM, [hidden email] wrote:
>> it works nicely with calling mashall/unmarshall myself, providing a
>> custom DataHolder. the only inconvenience is, that - calling
>> unmarshall - i need to know what the root-type is.
> PS: i just realized i could just pass null as the root object, so the
> above statement is plain wrong.

Yes, that argument is only required if you absolutely want to fill an
existing object.

> sorry, uwe

No problem,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email