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

public Class NamedCollectionConverter

extends CollectionConverter
Class Inheritance
Imports
com.thoughtworks.xstream.converters.MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.core.util.HierarchicalStreams, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper

A collection converter that uses predefined names for its items.

To be used as local converter. Note, suppress the usage of the implicit type argument, if registered with annotation.

Author
Jörg Schaible
Since
1.4.5

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
NamedCollectionConverter(Mapper
the mapper
mapper
,
String
the name of the items
itemName
,
Class<T>
the base type of the items
itemType
)

Constructs a NamedCollectionConverter.

public
NamedCollectionConverter(Class<T>
the Collection type to handle
type
,
Mapper
the mapper
mapper
,
String
the name of the items
itemName
,
Class<T>
the base type of the items
itemType
)

Constructs a NamedCollectionConverter handling an explicit Collection type.

Method Summary

Modifier and TypeMethod and Description
protected Object
readBareItem(final HierarchicalStreamReader
the source reader
reader
,
final UnmarshallingContext
the unmarshalling context
context
,
final Object
the target collection (if already available)
current
)

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

Read a bare item of the collection from the reader.
protected void
writeCompleteItem(final Object
the item to write
item
,
final MarshallingContext
the current marshalling context
context
,
final HierarchicalStreamWriter
the target writer
writer
)

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

Write an item of the collection into the writer including surrounding tags.
protected void
Inherited from com.thoughtworks.xstream.converters.collections.CollectionConverter:
addCurrentElementToCollectioncanConvertcreateCollectionmarshalpopulateCollectionpopulateCollectionunmarshal

Field Detail

nameback to summary
private final String name
typeback to summary
private final Class<T> type

Hides com.thoughtworks.xstream.converters.collections.CollectionConverter.type.

Constructor Detail

NamedCollectionConverterback to summary
public NamedCollectionConverter(Mapper mapper, String itemName, Class<T> itemType)

Constructs a NamedCollectionConverter.

Parameters
mapper:Mapper

the mapper

itemName:String

the name of the items

itemType:Class<T>

the base type of the items

Since
1.4.5
NamedCollectionConverterback to summary
public NamedCollectionConverter(Class<T> type, Mapper mapper, String itemName, Class<T> itemType)

Constructs a NamedCollectionConverter handling an explicit Collection type.

Parameters
type:Class<T>

the Collection type to handle

mapper:Mapper

the mapper

itemName:String

the name of the items

itemType:Class<T>

the base type of the items

Since
1.4.5

Method Detail

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

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

Doc from com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readBareItem.

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

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

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

Doc from com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeCompleteItem.

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

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

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