public class CollectionConverter extends AbstractCollectionConverter
Supports java.util.ArrayList, java.util.HashSet, java.util.LinkedList, java.util.Vector and java.util.LinkedHashSet.
Constructor and Description |
---|
CollectionConverter(Mapper mapper) |
CollectionConverter(Mapper mapper,
Class type)
Construct a CollectionConverter for a special Collection type.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCurrentElementToCollection(HierarchicalStreamReader reader,
UnmarshallingContext context,
Collection collection,
Collection target) |
boolean |
canConvert(Class type)
Determines whether the converter can marshall a particular type.
|
protected Object |
createCollection(Class type) |
void |
marshal(Object source,
HierarchicalStreamWriter writer,
MarshallingContext context)
Convert an object to textual data.
|
protected void |
populateCollection(HierarchicalStreamReader reader,
UnmarshallingContext context,
Collection collection) |
protected void |
populateCollection(HierarchicalStreamReader reader,
UnmarshallingContext context,
Collection collection,
Collection target) |
Object |
unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context)
Convert textual data back into an object.
|
mapper, readItem, writeItem
public CollectionConverter(Mapper mapper)
public boolean canConvert(Class type)
ConverterMatcher
canConvert
in interface ConverterMatcher
canConvert
in class AbstractCollectionConverter
type
- the Class representing the object type to be convertedpublic void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Converter
marshal
in interface Converter
marshal
in class AbstractCollectionConverter
source
- The object to be marshalled.writer
- A stream to write to.context
- A context that allows nested objects to be processed by XStream.public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Converter
unmarshal
in interface Converter
unmarshal
in class AbstractCollectionConverter
reader
- The stream to read the text from.protected void populateCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection collection)
protected void populateCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection collection, Collection target)
protected void addCurrentElementToCollection(HierarchicalStreamReader reader, UnmarshallingContext context, Collection collection, Collection target)
protected Object createCollection(Class type)
createCollection
in class AbstractCollectionConverter
Copyright © 2004–2017 XStream. All rights reserved.