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

public Class NamedArrayConverter

extends Object
implements Converter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher
Imports
java.lang.reflect.Array, java.util.ArrayList, .List, com.thoughtworks.xstream.converters.Converter, .MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.core.util.HierarchicalStreams, .Primitives, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper

An array converter that uses predefined names for its items.

To be used as local converter.

Author
Jörg Schaible
Since
1.4.6

Field Summary

Modifier and TypeField and Description
private final Class<T>
private final String
private final Mapper

Constructor Summary

AccessConstructor and Description
public
NamedArrayConverter(final Class<T> arrayType, final Mapper mapper, final String itemName)

Construct a NamedArrayConverter.

Method Summary

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

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

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

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

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

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

Convert textual data back into an object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayTypeback to summary
private final Class<T> arrayType
itemNameback to summary
private final String itemName
mapperback to summary
private final Mapper mapper

Constructor Detail

NamedArrayConverterback to summary
public NamedArrayConverter(final Class<T> arrayType, final Mapper mapper, final String itemName)

Construct a NamedArrayConverter.

Since
1.4.6

Method Detail

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

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

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

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.

unmarshalback to summary
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context)

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.