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

public Class MapConverter

extends AbstractCollectionConverter
Class Inheritance
Known Direct Subclasses
com.thoughtworks.xstream.converters.collections.SingletonMapConverter, com.thoughtworks.xstream.converters.collections.TreeMapConverter, com.thoughtworks.xstream.converters.enums.EnumMapConverter, com.thoughtworks.xstream.converters.extended.NamedMapConverter
Imports
com.thoughtworks.xstream.converters.MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.core.SecurityUtils, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper, java.util.HashMap, .Hashtable, .Iterator, .Map

Converts a java.util.Map to XML, specifying an 'entry' element with 'key' and 'value' children.

Note

'key' and 'value' is not the name of the generated tag. The children are serialized as normal elements and the implementation expects them in the order 'key'/'value'.

Supports java.util.HashMap, java.util.Hashtable, java.util.LinkedHashMap and java.util.concurrent.ConcurrentHashMap.

Author
Joe Walnes

Field Summary

Modifier and TypeField and Description
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
public
MapConverter(Mapper
the mapper
mapper
,
Class<T>
the type to handle
type
)

Construct a MapConverter for a special Map type.

Method Summary

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

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.canConvert.

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

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

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.marshal.

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

Convert an object to textual data.
protected void
protected void
populateMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map<K, V> map, Map<K, V> target)

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

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.unmarshal.

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

Convert textual data back into an object.
Inherited from com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter:
mapperreadBareItemreadCompleteItemreadItemwriteBareItemwriteCompleteItemwriteItemwriteNullItem

Field Detail

typeback to summary
private final Class<T> type

Constructor Detail

MapConverterback to summary
public MapConverter(Mapper mapper)
MapConverterback to summary
public MapConverter(Mapper mapper, Class<T> type)

Construct a MapConverter for a special Map type.

Parameters
mapper:Mapper

the mapper

type:Class<T>

the type to handle

Since
1.4.5

Method Detail

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

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.canConvert.

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

createCollectionback to summary
protected Object createCollection(Class<T> type)

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

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

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.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)
populateMapback to summary
protected void populateMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map<K, V> map, Map<K, V> target)
putCurrentEntryIntoMapback to summary
protected void putCurrentEntryIntoMap(HierarchicalStreamReader reader, UnmarshallingContext context, Map<K, V> map, Map<K, V> target)
unmarshalback to summary
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

Implements abstract com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.unmarshal.

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.