Hi Graham,

Graham Allan wrote:

> On 14 February 2012 19:41, Jörg Schaible
> <[email protected]> wrote:
> 
>> <snip>
> 
> So, you might say, that your collections do not have additional members.
>> Then you're free to register an own Collection converter that overloads
>> the canConvert method and returns true for every type that is assignable
>> to Collection. The situation for Iterable is similar, but you will also
>> have to
>> overload the marshal/unmarshal methods to read/write the class attribute
>> for
>> the concrete type and to initiate the loop.
>>
>>
> We do currently register our own converters for Iterable, and that's fine
> for our particular case (ignoring implementation specifics like you
> described). However, I don't think there's any way to register a converter
> to be picked up when using @XStreamImplicit. Please correct me if I'm
> wrong, if there's a way I can implement a converter which is invoked at
> the correct time, that would be great. Or even if I had to declare the
> annotation as something like
> @XStreamImplicit(converter=MyIterableConverter.class) that would be fine
> too.
> 
> Does such a feature exist currently?

No, because implicit collections are not handled by an own converter. It is 
more or less a hack into the (Abstract)ReflectionConverter. It is not 
possible to use a converter at that point anyway, because 
1/ the writer/reader state is wrong when a converter would be called (it can 
normally assume that it can write/read attributes of the current node 
representing the container and it has to moveDown for the first container 
element)
2/ a converter has to assume that all following elements are part of the 
collection

So, if you really want to support implicit collections on Iterable types, 
you will have to take a copy of AbstractReflectionConverter and hack the 
support into it.

- Jörg


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

    http://xircles.codehaus.org/manage_email


Reply via email to