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 classTreeMapConverter.NullComparatorprivate static classTreeMapConverter.Reflections
-
Field Summary
Fields Modifier and Type Field Description private static java.util.ComparatorNULL_MARKER
-
Constructor Summary
Constructors Constructor Description TreeMapConverter(Mapper mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidmarshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)Convert an object to textual data.protected voidmarshalComparator(java.util.Comparator comparator, HierarchicalStreamWriter writer, MarshallingContext context)protected voidpopulateTreeMap(HierarchicalStreamReader reader, UnmarshallingContext context, java.util.TreeMap result, java.util.Comparator comparator)java.lang.Objectunmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)Convert textual data back into an object.protected java.util.ComparatorunmarshalComparator(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:ConverterConvert an object to textual data.- Specified by:
marshalin interfaceConverter- Overrides:
marshalin 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:ConverterConvert textual data back into an object.- Specified by:
unmarshalin interfaceConverter- Overrides:
unmarshalin 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)
-
-