public class ObjectWithDefaultStringImplConverter
extends java.lang.Object
implements com.thoughtworks.xstream.converters.Converter
ConverterLookup.lookupConverterForType(Class), where
possible. On unmarshalling, if there is no class attribute then it assumes that the
type must be a String.
This is useful if a class has its field changed from type String to Object.
The old persisted state will look like <mykey>myval</mykey>, rather than
<mykey class="string">myval</mykey>.
Use this converter by annotation the field with
@XStreamConverter(ObjectWithDefaultStringImplConverter.class). One must also call
xstream.processAnnotations(MyClazz.class) to ensure the annotation is actually parsed.| Constructor and Description |
|---|
ObjectWithDefaultStringImplConverter(com.thoughtworks.xstream.converters.ConverterLookup lookup,
com.thoughtworks.xstream.core.ClassLoaderReference loader) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canConvert(java.lang.Class type) |
void |
marshal(java.lang.Object source,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context) |
java.lang.Object |
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context) |
public ObjectWithDefaultStringImplConverter(com.thoughtworks.xstream.converters.ConverterLookup lookup,
com.thoughtworks.xstream.core.ClassLoaderReference loader)
public boolean canConvert(java.lang.Class type)
canConvert in interface com.thoughtworks.xstream.converters.ConverterMatcherpublic void marshal(java.lang.Object source,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context)
marshal in interface com.thoughtworks.xstream.converters.Converterpublic java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context)
unmarshal in interface com.thoughtworks.xstream.converters.Converter