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

public Class NamedMapConverter

extends MapConverter
Class Inheritance
Imports
java.util.Iterator, .Map, com.thoughtworks.xstream.converters.ConversionException, .Converter, .ConverterLookup, .MarshallingContext, .SingleValueConverter, .UnmarshallingContext, com.thoughtworks.xstream.converters.collections.MapConverter, com.thoughtworks.xstream.core.JVM, .SecurityUtils, com.thoughtworks.xstream.core.util.HierarchicalStreams, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper

A map converter that uses predefined names for its elements.

To be used as local converter. Note, suppress the usage of the implicit type argument, if registered with annotation. Depending on the constructor arguments it is possible to support various formats:

Author
Jörg Schaible
Since
1.4.5

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
NamedMapConverter(Mapper
the mapper
mapper
,
String
the name of the entry elements
entryName
,
String
the name of the key elements
keyName
,
Class<T>
the base type of key elements
keyType
,
String
the name of the value elements
valueName
,
Class<T>
the base type of value elements
valueType
)

Constructs a NamedMapConverter.

public
NamedMapConverter(Class<T>
the Map type this instance will handle
type
,
Mapper
the mapper
mapper
,
String
the name of the entry elements
entryName
,
String
the name of the key elements
keyName
,
Class<T>
the base type of key elements
keyType
,
String
the name of the value elements
valueName
,
Class<T>
the base type of value elements
valueType
)

Constructs a NamedMapConverter handling an explicit Map type.

public
NamedMapConverter(Mapper
the mapper
mapper
,
String
the name of the entry elements
entryName
,
String
the name of the key elements
keyName
,
Class<T>
the base type of key elements
keyType
,
String
the name of the value elements
valueName
,
Class<T>
the base type of value elements
valueType
,
boolean
flag to write key as attribute of entry element
keyAsAttribute
,
boolean
flag to write value as attribute of entry element
valueAsAttribute
,
ConverterLookup
used to lookup SingleValueConverter for attributes
lookup
)

Constructs a NamedMapConverter with attribute support.

public
NamedMapConverter(Class<T>
the Map type this instance will handle
type
,
Mapper
the mapper
mapper
,
String
the name of the entry elements
entryName
,
String
the name of the key elements
keyName
,
Class<T>
the base type of key elements
keyType
,
String
the name of the value elements
valueName
,
Class<T>
the base type of value elements
valueType
,
boolean
flag to write key as attribute of entry element
keyAsAttribute
,
boolean
flag to write value as attribute of entry element
valueAsAttribute
,
ConverterLookup
used to lookup SingleValueConverter for attributes
lookup
)

Constructs a NamedMapConverter with attribute support handling an explicit Map type.

Method Summary

Modifier and TypeMethod and Description
private SingleValueConverter
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
)

Overrides com.thoughtworks.xstream.converters.collections.MapConverter.marshal.

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

Convert an object to textual data.
protected void
protected Object
protected void
Inherited from com.thoughtworks.xstream.converters.collections.MapConverter:
canConvertcreateCollectionpopulateMapputCurrentEntryIntoMapunmarshal

Field Detail

entryNameback to summary
private final String entryName
enumMapperback to summary
private final Mapper enumMapper
keyAsAttributeback to summary
private final boolean keyAsAttribute
keyNameback to summary
private final String keyName
keyTypeback to summary
private final Class<T> keyType
lookupback to summary
private final ConverterLookup lookup
valueAsAttributeback to summary
private final boolean valueAsAttribute
valueNameback to summary
private final String valueName
valueTypeback to summary
private final Class<T> valueType

Constructor Detail

NamedMapConverterback to summary
public NamedMapConverter(Mapper mapper, String entryName, String keyName, Class<T> keyType, String valueName, Class<T> valueType)

Constructs a NamedMapConverter.

Parameters
mapper:Mapper

the mapper

entryName:String

the name of the entry elements

keyName:String

the name of the key elements

keyType:Class<T>

the base type of key elements

valueName:String

the name of the value elements

valueType:Class<T>

the base type of value elements

Since
1.4.5
NamedMapConverterback to summary
public NamedMapConverter(Class<T> type, Mapper mapper, String entryName, String keyName, Class<T> keyType, String valueName, Class<T> valueType)

Constructs a NamedMapConverter handling an explicit Map type.

Parameters
type:Class<T>

the Map type this instance will handle

mapper:Mapper

the mapper

entryName:String

the name of the entry elements

keyName:String

the name of the key elements

keyType:Class<T>

the base type of key elements

valueName:String

the name of the value elements

valueType:Class<T>

the base type of value elements

Since
1.4.5
NamedMapConverterback to summary
public NamedMapConverter(Mapper mapper, String entryName, String keyName, Class<T> keyType, String valueName, Class<T> valueType, boolean keyAsAttribute, boolean valueAsAttribute, ConverterLookup lookup)

Constructs a NamedMapConverter with attribute support.

Parameters
mapper:Mapper

the mapper

entryName:String

the name of the entry elements

keyName:String

the name of the key elements

keyType:Class<T>

the base type of key elements

valueName:String

the name of the value elements

valueType:Class<T>

the base type of value elements

keyAsAttribute:boolean

flag to write key as attribute of entry element

valueAsAttribute:boolean

flag to write value as attribute of entry element

lookup:ConverterLookup

used to lookup SingleValueConverter for attributes

Since
1.4.5
NamedMapConverterback to summary
public NamedMapConverter(Class<T> type, Mapper mapper, String entryName, String keyName, Class<T> keyType, String valueName, Class<T> valueType, boolean keyAsAttribute, boolean valueAsAttribute, ConverterLookup lookup)

Constructs a NamedMapConverter with attribute support handling an explicit Map type.

Parameters
type:Class<T>

the Map type this instance will handle

mapper:Mapper

the mapper

entryName:String

the name of the entry elements

keyName:String

the name of the key elements

keyType:Class<T>

the base type of key elements

valueName:String

the name of the value elements

valueType:Class<T>

the base type of value elements

keyAsAttribute:boolean

flag to write key as attribute of entry element

valueAsAttribute:boolean

flag to write value as attribute of entry element

lookup:ConverterLookup

used to lookup SingleValueConverter for attributes

Since
1.4.5

Method Detail

getSingleValueConverterback to summary
private SingleValueConverter getSingleValueConverter(Class<T> type, String part)
marshalback to summary
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Overrides com.thoughtworks.xstream.converters.collections.MapConverter.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.

populateMapback to summary
protected void populateMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map<K, V> map, Map<K, V> target)

Overrides com.thoughtworks.xstream.converters.collections.MapConverter.populateMap.

readItemback to summary
protected Object readItem(Class<T> type, HierarchicalStreamReader reader, UnmarshallingContext context, Object current)
writeItemback to summary
protected void writeItem(String name, Class<T> type, Object item, MarshallingContext context, HierarchicalStreamWriter writer)