public abstract class

AbstractCollectionConverter

extends Object
implements Converter
java.lang.Object
   ↳ com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Summary

Public Constructors
AbstractCollectionConverter(Mapper mapper)
Public Methods
abstract boolean canConvert(Class type)
Determines whether the converter can marshall a particular type.
abstract void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Convert an object to textual data.
abstract Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Convert textual data back into an object.
Protected Methods
Object createCollection(Class type)
Mapper mapper()
Object readItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current)
void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.thoughtworks.xstream.converters.Converter
From interface com.thoughtworks.xstream.converters.ConverterMatcher

Public Constructors

public AbstractCollectionConverter (Mapper mapper)

Public Methods

public abstract boolean canConvert (Class type)

Determines whether the converter can marshall a particular type.

Parameters
type the Class representing the object type to be converted

public abstract void marshal (Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Convert an object to textual data.

Parameters
source The object to be marshalled.
writer A stream to write to.
context A context that allows nested objects to be processed by XStream.

public abstract Object unmarshal (HierarchicalStreamReader reader, UnmarshallingContext context)

Convert textual data back into an object.

Parameters
reader The stream to read the text from.
Returns
  • The resulting object.

Protected Methods

protected Object createCollection (Class type)

protected Mapper mapper ()

protected Object readItem (HierarchicalStreamReader reader, UnmarshallingContext context, Object current)

protected void writeItem (Object item, MarshallingContext context, HierarchicalStreamWriter writer)