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

public Class TreeMapConverter

extends MapConverter
Class Inheritance
Imports
com.thoughtworks.xstream.converters.MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.converters.reflection.ObjectAccessException, com.thoughtworks.xstream.core.JVM, com.thoughtworks.xstream.core.util.Fields, .HierarchicalStreams, .PresortedMap, com.thoughtworks.xstream.io.HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper, java.lang.reflect.Field, java.util.Comparator, .SortedMap, .TreeMap

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.
Authors
Joe Walnes, Jörg Schaible

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final Comparator<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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 void
populateTreeMap(HierarchicalStreamReader reader, UnmarshallingContext context, TreeMap<K, V> result, Comparator<T> comparator)

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

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

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

Convert textual data back into an object.
protected Comparator<T>
Inherited from com.thoughtworks.xstream.converters.collections.MapConverter:
canConvertcreateCollectionpopulateMappopulateMapputCurrentEntryIntoMap

Field Detail

NULL_MARKERback to summary
private static final Comparator<T> NULL_MARKER

Constructor Detail

TreeMapConverterback to summary
public TreeMapConverter(Mapper mapper)

Method Detail

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.

marshalComparatorback to summary
protected void marshalComparator(Comparator<T> comparator, HierarchicalStreamWriter writer, MarshallingContext context)
populateTreeMapback to summary
protected void populateTreeMap(HierarchicalStreamReader reader, UnmarshallingContext context, TreeMap<K, V> result, Comparator<T> comparator)
unmarshalback to summary
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

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

unmarshalComparatorback to summary
protected Comparator<T> unmarshalComparator(HierarchicalStreamReader reader, UnmarshallingContext context, TreeMap<K, V> result)
com.thoughtworks.xstream.converters.collections back to summary

private final Class TreeMapConverter.NullComparator

extends Null
implements Comparator
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(Object
the first object to be compared.
o1
,
Object
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Constructor Detail

NullComparatorback to summary
private NullComparator()

Method Detail

compareback to summary
public int compare(Object o1, Object o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:Object

the first object to be compared.

o2:Object

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

com.thoughtworks.xstream.converters.collections back to summary

private Class TreeMapConverter.Reflections

extends Object
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.converters.collections.TreeMapConverter.Reflections

Field Summary

Modifier and TypeField and Description
private static final Field

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

comparatorFieldback to summary
private static final Field comparatorField

Constructor Detail

Reflectionsback to summary
private Reflections()