com.thoughtworks.xstream.converters.collections
Class SingletonCollectionConverter

java.lang.Object
  extended by com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
      extended by com.thoughtworks.xstream.converters.collections.CollectionConverter
          extended by com.thoughtworks.xstream.converters.collections.SingletonCollectionConverter
All Implemented Interfaces:
Converter, ConverterMatcher

public class SingletonCollectionConverter
extends CollectionConverter

Converts singleton collections (list and set) to XML, specifying a nested element for the item.

Supports Collections.singleton(Object) and Collections.singletonList(Object).

Since:
1.4.2
Author:
Jörg Schaible

Constructor Summary
SingletonCollectionConverter(Mapper mapper)
          Construct a SingletonCollectionConverter.
 
Method Summary
 boolean canConvert(Class type)
          Determines whether the converter can marshall a particular type.
 Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
          Convert textual data back into an object.
 
Methods inherited from class com.thoughtworks.xstream.converters.collections.CollectionConverter
addCurrentElementToCollection, marshal, populateCollection, populateCollection
 
Methods inherited from class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
createCollection, mapper, readItem, writeItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonCollectionConverter

public SingletonCollectionConverter(Mapper mapper)
Construct a SingletonCollectionConverter.

Parameters:
mapper - the mapper
Since:
1.4.2
Method Detail

canConvert

public boolean canConvert(Class type)
Description copied from interface: ConverterMatcher
Determines whether the converter can marshall a particular type.

Specified by:
canConvert in interface ConverterMatcher
Overrides:
canConvert in class CollectionConverter
Parameters:
type - the Class representing the object type to be converted

unmarshal

public Object unmarshal(HierarchicalStreamReader reader,
                        UnmarshallingContext context)
Description copied from interface: Converter
Convert textual data back into an object.

Specified by:
unmarshal in interface Converter
Overrides:
unmarshal in class CollectionConverter
Parameters:
reader - The stream to read the text from.
Returns:
The resulting object.


Copyright © 2004-2014 XStream. All Rights Reserved.