Top Description Fields Constructors Methods
com.thoughtworks.xstream.converters.collections

public Class CollectionConverter

extends AbstractCollectionConverter
Class Inheritance
Known Direct Subclasses
com.thoughtworks.xstream.converters.collections.SingletonCollectionConverter, com.thoughtworks.xstream.converters.collections.TreeSetConverter, com.thoughtworks.xstream.converters.extended.NamedCollectionConverter
Imports
com.thoughtworks.xstream.converters.MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.core.SecurityUtils, com.thoughtworks.xstream.io.HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper, java.util.ArrayList, .Collection, .HashSet, .Iterator, .LinkedHashSet, .LinkedList, .Vector

Converts most common Collections (Lists and Sets) to XML, specifying a nested element for each item.

Supports java.util.ArrayList, java.util.HashSet, java.util.LinkedList, java.util.Vector and java.util.LinkedHashSet.

Author
Joe Walnes

Field Summary

Modifier and TypeField and Description
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
public
CollectionConverter(Mapper
the mapper
mapper
,
Class<T>
the Collection type to handle
type
)

Construct a CollectionConverter for a special Collection type.

Method Summary

Modifier and TypeMethod and Description
protected void
public boolean
canConvert(Class<T>
the Class representing the object type to be converted
type
)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.canConvert.

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.
protected Object
public void
marshal(Object
The object to be marshalled.
source
,
HierarchicalStreamWriter
A stream to write to.
writer
,
MarshallingContext
A context that allows nested objects to be processed by XStream.
context
)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.marshal.

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.
protected void
protected void
public Object
unmarshal(HierarchicalStreamReader
The stream to read the text from.
reader
,
UnmarshallingContext context)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.unmarshal.

Implements com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.
Inherited from com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter:
mapperreadBareItemreadCompleteItemreadItemwriteBareItemwriteCompleteItemwriteItemwriteNullItem

Field Detail

typeback to summary
private final Class<T> type

Constructor Detail

CollectionConverterback to summary
public CollectionConverter(Mapper mapper)
CollectionConverterback to summary
public CollectionConverter(Mapper mapper, Class<T> type)

Construct a CollectionConverter for a special Collection type.

Parameters
mapper:Mapper

the mapper

type:Class<T>

the Collection type to handle

Since
1.4.5

Method Detail

addCurrentElementToCollectionback to summary
protected void addCurrentElementToCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection<E> collection, Collection<E> target)
canConvertback to summary
public boolean canConvert(Class<T> type)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.canConvert.

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Doc from com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.

Parameters
type:Class<T>

the Class representing the object type to be converted

createCollectionback to summary
protected Object createCollection(Class<T> type)

Overrides com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.createCollection.

marshalback to summary
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.marshal.

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Doc from com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.

Parameters
source:Object

The object to be marshalled.

writer:HierarchicalStreamWriter

A stream to write to.

context:MarshallingContext

A context that allows nested objects to be processed by XStream.

populateCollectionback to summary
protected void populateCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection<E> collection)
populateCollectionback to summary
protected void populateCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection<E> collection, Collection<E> target)
unmarshalback to summary
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.unmarshal.

Implements com.thoughtworks.xstream.converters.Converter.unmarshal.

Doc from com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.

Parameters
reader:HierarchicalStreamReader

The stream to read the text from.

Returns:Object

The resulting object.