Class AbstractCollectionConverter
java.lang.Object
com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
- All Implemented Interfaces:
Converter, ConverterMatcher
- Direct Known Subclasses:
ArrayConverter, CollectionConverter, MapConverter, SubjectConverter
Base helper class for converters that need to handle
collections of items (arrays, Lists, Maps, etc).
Typically, subclasses of this will converter the outer structure of the collection, loop through the contents and call readItem() or writeItem() for each item.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancanConvert(Class type) Determines whether the converter can marshall a particular type.protected ObjectcreateCollection(Class type) protected Mappermapper()abstract voidmarshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) Convert an object to textual data.protected ObjectreadBareItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Read a bare item of the collection from the reader.protected ObjectreadCompleteItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Read an item of the collection including the tags from the reader.protected ObjectreadItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Deprecated.abstract Objectunmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) Convert textual data back into an object.protected voidwriteBareItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) Write the bare item of the collection into the writer.protected voidwriteCompleteItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) Write an item of the collection into the writer including surrounding tags.protected voidwriteItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) Deprecated.As of 1.4.11 usewriteCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)instead.protected voidwriteNullItem(MarshallingContext context, HierarchicalStreamWriter writer) Write a null item of the collection into the writer.
-
Field Details
-
mapper
-
-
Constructor Details
-
AbstractCollectionConverter
-
-
Method Details
-
canConvert
Description copied from interface:ConverterMatcherDetermines whether the converter can marshall a particular type.- Specified by:
canConvertin interfaceConverterMatcher- Parameters:
type- the Class representing the object type to be converted
-
mapper
-
marshal
public abstract void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) Description copied from interface:ConverterConvert an object to textual data. -
unmarshal
Description copied from interface:ConverterConvert textual data back into an object. -
writeItem
Deprecated.As of 1.4.11 usewriteCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)instead. -
writeCompleteItem
protected void writeCompleteItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) Write an item of the collection into the writer including surrounding tags.- Parameters:
item- the item to writecontext- the current marshalling contextwriter- the target writer- Since:
- 1.4.11
-
writeBareItem
protected void writeBareItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) Write the bare item of the collection into the writer.- Parameters:
item- the item to writecontext- the current marshalling contextwriter- the target writer- Since:
- 1.4.11
-
writeNullItem
Write a null item of the collection into the writer. The method readItem should be able to process the written data i.e. it has to write the tags or may not write anything at all.- Parameters:
context- the current marshalling contextwriter- the target writer- Since:
- 1.4.11
-
readItem
protected Object readItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Deprecated. -
readBareItem
protected Object readBareItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Read a bare item of the collection from the reader.- Parameters:
reader- the source readercontext- the unmarshalling contextcurrent- the target collection (if already available)- Returns:
- the read item
- Since:
- 1.4.11
-
readCompleteItem
protected Object readCompleteItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) Read an item of the collection including the tags from the reader.- Parameters:
reader- the source readercontext- the unmarshalling contextcurrent- the target collection (if already available)- Returns:
- the read item
- Since:
- 1.4.11
-
createCollection
-
readBareItem(HierarchicalStreamReader, UnmarshallingContext, Object)orreadCompleteItem(HierarchicalStreamReader, UnmarshallingContext, Object)instead.