Class TreeMapConverter
- java.lang.Object
-
- com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
-
- com.thoughtworks.xstream.converters.collections.MapConverter
-
- com.thoughtworks.xstream.converters.collections.TreeMapConverter
-
- All Implemented Interfaces:
Converter
,ConverterMatcher
public class TreeMapConverter extends MapConverter
Converts a java.util.TreeMap to XML, and serializes the associated java.util.Comparator. The converter assumes that the entries in the XML are already sorted according the comparator.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TreeMapConverter.NullComparator
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Field
comparatorField
private static java.util.Comparator
NULL_MARKER
-
Constructor Summary
Constructors Constructor Description TreeMapConverter(Mapper mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Convert an object to textual data.protected void
marshalComparator(java.util.Comparator comparator, HierarchicalStreamWriter writer, MarshallingContext context)
protected void
populateTreeMap(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.TreeMap result, java.util.Comparator comparator)
java.lang.Object
unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Convert textual data back into an object.protected java.util.Comparator
unmarshalComparator(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.TreeMap result)
-
Methods inherited from class com.thoughtworks.xstream.converters.collections.MapConverter
canConvert, createCollection, populateMap, populateMap, putCurrentEntryIntoMap
-
Methods inherited from class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
mapper, readBareItem, readCompleteItem, readItem, writeBareItem, writeCompleteItem, writeItem, writeNullItem
-
-
-
-
Constructor Detail
-
TreeMapConverter
public TreeMapConverter(Mapper mapper)
-
-
Method Detail
-
marshal
public void marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Description copied from interface:Converter
Convert an object to textual data.- Specified by:
marshal
in interfaceConverter
- Overrides:
marshal
in classMapConverter
- 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.
-
marshalComparator
protected void marshalComparator(java.util.Comparator comparator, HierarchicalStreamWriter writer, MarshallingContext context)
-
unmarshal
public java.lang.Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Description copied from interface:Converter
Convert textual data back into an object.- Specified by:
unmarshal
in interfaceConverter
- Overrides:
unmarshal
in classMapConverter
- Parameters:
reader
- The stream to read the text from.- Returns:
- The resulting object.
-
unmarshalComparator
protected java.util.Comparator unmarshalComparator(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.TreeMap result)
-
populateTreeMap
protected void populateTreeMap(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.TreeMap result, java.util.Comparator comparator)
-
-