public class AliasingListConverter
extends java.lang.Object
implements com.thoughtworks.xstream.converters.Converter
Minor modification of the sample code posted by Joerg Schaible in a September 19, 2008 message on the java.xstream.user message board.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
alias
Alias for list entries.
|
protected java.lang.Class<?> |
type
Typeof list to convert.
|
Constructor and Description |
---|
AliasingListConverter(java.lang.Class<?> type,
java.lang.String alias)
Create converter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canConvert(java.lang.Class type)
Check that this converter can actually convert the specified list.
|
void |
marshal(java.lang.Object source,
com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
com.thoughtworks.xstream.converters.MarshallingContext context)
Marshall the list to a writer.
|
java.lang.Object |
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
com.thoughtworks.xstream.converters.UnmarshallingContext context)
Unmarshall the list from a reader.
|
protected java.lang.Class<?> type
protected java.lang.String alias
public AliasingListConverter(java.lang.Class<?> type, java.lang.String alias)
type
- Type of list to convert.alias
- Alias for list entries.public boolean canConvert(java.lang.Class type)
canConvert
in interface com.thoughtworks.xstream.converters.ConverterMatcher
type
- Type of list to convert.public 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.Converter
source
- The list to convert.writer
- Writer to which to marshall converted list.context
- Marshalling context.public java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
unmarshal
in interface com.thoughtworks.xstream.converters.Converter
reader
- The reader from which to unmarshall the list.context
- The unmarshalling context.