com.thoughtworks.xstream.converters
Interface Converter

All Known Implementing Classes:
AbstractBasicConverter, AbstractCollectionConverter, BitSetConverter, CharArrayConverter, ColorConverter, DynamicProxyConverter, EncodedByteArrayConverter, FontConverter, GregorianCalendarConverter, JavaMethodConverter, NullConverter, PropertiesConverter, ReflectionConverter, RegexPatternConverter, ThrowableConverter

public interface Converter

Converter implementations are responsible marshalling Java objects to/from textual data.

If an exception occurs during processing, a ConversionException should be thrown.

If working with the high level XStream facade, you can register new converters using the XStream.registerConverter() method.

If working with the lower level API, the ConverterLookup implementation is responsible for looking up the appropriate converter.

AbstractBasicConverter provides a starting point for objects that can store all information in a single String.

AbstractCollectionConverter provides a starting point for objects that hold a collection of other objects (such as Lists and Maps).

Author:
Joe Walnes
See Also:
XStream, ConverterLookup, AbstractBasicConverter, AbstractCollectionConverter

Method Summary
 boolean canConvert(java.lang.Class type)
          Called by XStream to determine whether to use this converter instance to marshall a particular type.
 void marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
          Convert an object to textual data.
 java.lang.Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
          Convert textual data back into an object.
 

Method Detail

canConvert

public boolean canConvert(java.lang.Class type)
Called by XStream to determine whether to use this converter instance to marshall a particular type.


marshal

public void marshal(java.lang.Object source,
                    HierarchicalStreamWriter writer,
                    MarshallingContext context)
Convert an object to textual data.

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.

unmarshal

public java.lang.Object unmarshal(HierarchicalStreamReader reader,
                                  UnmarshallingContext context)
Convert textual data back into an object.

Parameters:
reader - The stream to read the text from.
context -
Returns:
The resulting object.


Joe Walnes, http://xstream.codehaus.org/