public abstract class AbstractCollectionConverter extends java.lang.Object implements Converter
Typically, subclasses of this will converter the outer structure of the collection, loop through the contents and call readItem() or writeItem() for each item.
Constructor and Description |
---|
AbstractCollectionConverter(Mapper mapper) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canConvert(java.lang.Class type)
Determines whether the converter can marshall a particular type.
|
protected java.lang.Object |
createCollection(java.lang.Class type) |
protected Mapper |
mapper() |
abstract void |
marshal(java.lang.Object source,
HierarchicalStreamWriter writer,
MarshallingContext context)
Convert an object to textual data.
|
protected java.lang.Object |
readBareItem(HierarchicalStreamReader reader,
UnmarshallingContext context,
java.lang.Object current)
Read a bare item of the collection from the reader.
|
protected java.lang.Object |
readCompleteItem(HierarchicalStreamReader reader,
UnmarshallingContext context,
java.lang.Object current)
Read an item of the collection including the tags from the reader.
|
protected java.lang.Object |
readItem(HierarchicalStreamReader reader,
UnmarshallingContext context,
java.lang.Object current)
Deprecated.
|
abstract java.lang.Object |
unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context)
Convert textual data back into an object.
|
protected void |
writeBareItem(java.lang.Object item,
MarshallingContext context,
HierarchicalStreamWriter writer)
Write the bare item of the collection into the writer.
|
protected void |
writeCompleteItem(java.lang.Object item,
MarshallingContext context,
HierarchicalStreamWriter writer)
Write an item of the collection into the writer including surrounding tags.
|
protected void |
writeItem(java.lang.Object item,
MarshallingContext context,
HierarchicalStreamWriter writer)
Deprecated.
As of 1.4.11 use
writeCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)
instead. |
protected void |
writeNullItem(MarshallingContext context,
HierarchicalStreamWriter writer)
Write a null item of the collection into the writer.
|
public AbstractCollectionConverter(Mapper mapper)
public abstract boolean canConvert(java.lang.Class type)
ConverterMatcher
canConvert
in interface ConverterMatcher
type
- the Class representing the object type to be convertedprotected Mapper mapper()
public abstract void marshal(java.lang.Object source, HierarchicalStreamWriter writer, MarshallingContext context)
Converter
public abstract java.lang.Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
Converter
protected void writeItem(java.lang.Object item, MarshallingContext context, HierarchicalStreamWriter writer)
writeCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)
instead.protected void writeCompleteItem(java.lang.Object item, MarshallingContext context, HierarchicalStreamWriter writer)
item
- the item to writecontext
- the current marshalling contextwriter
- the target writerprotected void writeBareItem(java.lang.Object item, MarshallingContext context, HierarchicalStreamWriter writer)
item
- the item to writecontext
- the current marshalling contextwriter
- the target writerprotected void writeNullItem(MarshallingContext context, HierarchicalStreamWriter writer)
context
- the current marshalling contextwriter
- the target writerprotected java.lang.Object readItem(HierarchicalStreamReader reader, UnmarshallingContext context, java.lang.Object current)
readBareItem(HierarchicalStreamReader, UnmarshallingContext, Object)
or
readCompleteItem(HierarchicalStreamReader, UnmarshallingContext, Object)
instead.protected java.lang.Object readBareItem(HierarchicalStreamReader reader, UnmarshallingContext context, java.lang.Object current)
reader
- the source readercontext
- the unmarshalling contextcurrent
- the target collection (if already available)protected java.lang.Object readCompleteItem(HierarchicalStreamReader reader, UnmarshallingContext context, java.lang.Object current)
reader
- the source readercontext
- the unmarshalling contextcurrent
- the target collection (if already available)protected java.lang.Object createCollection(java.lang.Class type)
Copyright © 2004–2022 XStream. All rights reserved.