Hi John,

John Fereira wrote:

> One more followup question related to the Custom Converter I created.  
> It's more of a curiosity than anything, but when serializing a List object
> and the items of the list are strings, why is the element wrapper for each
> item set to "string" (all lower case)?

XStream's collection converters use the item's type as tag for the 
individual elements. Since java.lang.String is aliased to "string", it will 
use the alias.

> In my custom converter I am
> marshaling an object which contains a List as one of its fields, and
> because that List object might be null I'm marshaling the list as an empty
> list rather than excluding the element.

XStream's converters will always have to separate between null and an empty 
list. You're free to do something else in a custom converter as long as it 
fits into your object model.

> When the list does have items I'm
> setting the wrapper element to  value.getClass().getSimpleName(), which
> for a list of Strings will return "String" (note the upper case 'S').

As long as your converter knows how to recreate all the items from this tag, 
you can chose whatever you want. Any reason not to call 
context.convertAnother for XStream to the list?

> I just wondered what the rational was for using an all lowercase 
> representation of the object type.

All default aliases in XStream are lowercase and will use hyphens. If you 
want to know why, you'll have to wait for Joe's answer, he started the 
project 8 years ago ;-)

Cheers,
Jörg


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

    http://xircles.codehaus.org/manage_email


Reply via email to