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

public abstract Class AbstractCollectionConverter

extends Object
implements Converter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher
Known Direct Subclasses
com.thoughtworks.xstream.converters.collections.ArrayConverter, com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.converters.extended.SubjectConverter
Imports
com.thoughtworks.xstream.converters.ConversionException, .Converter, .ErrorWritingException, .MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.converters.reflection.ObjectAccessException, com.thoughtworks.xstream.core.util.HierarchicalStreams, com.thoughtworks.xstream.io.HierarchicalStreamReader, .HierarchicalStreamWriter, .ExtendedHierarchicalStreamWriterHelper, com.thoughtworks.xstream.mapper.Mapper

Base helper class for converters that need to handle collections of items (arrays, Lists, Maps, etc).

Typically, subclasses of this will converter the outer structure of the collection, loop through the contents and call readItem() or writeItem() for each item.

Author
Joe Walnes

Field Summary

Modifier and TypeField and Description
private final Mapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Redeclares com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.
protected Object
protected Mapper
public abstract 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
)

Redeclares com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.
protected Object

Returns:

the read item
readBareItem
(final HierarchicalStreamReader
the source reader
reader
,
final UnmarshallingContext
the unmarshalling context
context
,
final Object
the target collection (if already available)
current
)

Read a bare item of the collection from the reader.

protected Object

Returns:

the read item
readCompleteItem
(final HierarchicalStreamReader
the source reader
reader
,
final UnmarshallingContext
the unmarshalling context
context
,
final Object
the target collection (if already available)
current
)

Read an item of the collection including the tags from the reader.

protected Object
public abstract Object
unmarshal(HierarchicalStreamReader
The stream to read the text from.
reader
,
UnmarshallingContext context)

Redeclares com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.
protected void
writeBareItem(final Object
the item to write
item
,
final MarshallingContext
the current marshalling context
context
,
final HierarchicalStreamWriter
the target writer
writer
)

Write the bare item of the collection into the writer.

protected void
writeCompleteItem(final Object
the item to write
item
,
final MarshallingContext
the current marshalling context
context
,
final HierarchicalStreamWriter
the target writer
writer
)

Write an item of the collection into the writer including surrounding tags.

protected void
protected void
writeNullItem(final MarshallingContext
the current marshalling context
context
,
final HierarchicalStreamWriter
the target writer
writer
)

Write a null item of the collection into the writer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapperback to summary
private final Mapper mapper

Constructor Detail

AbstractCollectionConverterback to summary
public AbstractCollectionConverter(Mapper mapper)

Method Detail

canConvertback to summary
public abstract boolean canConvert(Class<T> type)

Redeclares 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)
mapperback to summary
protected Mapper mapper()
marshalback to summary
public abstract void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Redeclares 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.

readBareItemback to summary
protected Object readBareItem(final HierarchicalStreamReader reader, final UnmarshallingContext context, final Object current)

Read a bare item of the collection from the reader.

Parameters
reader:HierarchicalStreamReader

the source reader

context:UnmarshallingContext

the unmarshalling context

current:Object

the target collection (if already available)

Returns:Object

the read item

Since
1.4.11
readCompleteItemback to summary
protected Object readCompleteItem(final HierarchicalStreamReader reader, final UnmarshallingContext context, final Object current)

Read an item of the collection including the tags from the reader.

Parameters
reader:HierarchicalStreamReader

the source reader

context:UnmarshallingContext

the unmarshalling context

current:Object

the target collection (if already available)

Returns:Object

the read item

Since
1.4.11
readItemback to summary
protected Object readItem(final HierarchicalStreamReader reader, final UnmarshallingContext context, final Object current)
unmarshalback to summary
public abstract Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

Redeclares 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.

writeBareItemback to summary
protected void writeBareItem(final Object item, final MarshallingContext context, final HierarchicalStreamWriter writer)

Write the bare item of the collection into the writer.

Parameters
item:Object

the item to write

context:MarshallingContext

the current marshalling context

writer:HierarchicalStreamWriter

the target writer

Since
1.4.11
writeCompleteItemback to summary
protected void writeCompleteItem(final Object item, final MarshallingContext context, final HierarchicalStreamWriter writer)

Write an item of the collection into the writer including surrounding tags.

Parameters
item:Object

the item to write

context:MarshallingContext

the current marshalling context

writer:HierarchicalStreamWriter

the target writer

Since
1.4.11
writeItemback to summary
protected void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer)
writeNullItemback to summary
protected void writeNullItem(final MarshallingContext context, final HierarchicalStreamWriter writer)

Write a null item of the collection into the writer. The method readItem should be able to process the written data i.e. it has to write the tags or may not write anything at all.

Parameters
context:MarshallingContext

the current marshalling context

writer:HierarchicalStreamWriter

the target writer

Since
1.4.11