Top Description Fields Constructors Methods
com.thoughtworks.xstream.converters.extended

public Class EncodedByteArrayConverter

extends Object
implements Converter, SingleValueConverter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.SingleValueConverter, com.thoughtworks.xstream.converters.ConverterMatcher, com.thoughtworks.xstream.converters.Converter
Imports
com.thoughtworks.xstream.converters.Converter, .MarshallingContext, .SingleValueConverter, .UnmarshallingContext, com.thoughtworks.xstream.converters.basic.ByteConverter, com.thoughtworks.xstream.core.JVM, .StringCodec, com.thoughtworks.xstream.io.HierarchicalStreamReader, .HierarchicalStreamWriter, java.util.ArrayList, .Iterator, .List

Converts a byte array by default to a single Base64 encoding string.
Authors
Joe Walnes, Jörg Schaible

Field Summary

Modifier and TypeField and Description
private static final ByteConverter
private final StringCodec

Constructor Summary

AccessConstructor and Description
public
EncodedByteArrayConverter()

Constructs an EncodedByteArrayConverter.

public
EncodedByteArrayConverter(final StringCodec
the codec to encode and decode the data as string
stringCodec
)

Constructs an EncodedByteArrayConverter with a provided string codec.

Method Summary

Modifier and TypeMethod and Description
public boolean
canConvert(Class<T>
the Class representing the object type to be converted
type
)

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.
public Object
fromString(final String
the String with the single value of the Object
str
)

Implements com.thoughtworks.xstream.converters.SingleValueConverter.fromString.

Unmarshals an Object from its single value representation.
public void
marshal(Object
The object to be marshalled.
source
,
HierarchicalStreamWriter
A stream to write to.
writer
,
MarshallingContext
A context that allows nested objects to be processed by XStream.
context
)

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.
public String
toString(final Object
the Object to be converted
obj
)

Implements com.thoughtworks.xstream.converters.SingleValueConverter.toString.

Marshals an Object into a single value representation.
public Object
unmarshal(HierarchicalStreamReader
The stream to read the text from.
reader
,
UnmarshallingContext context)

Implements com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.
private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteConverterback to summary
private static final ByteConverter byteConverter
codecback to summary
private final StringCodec codec

Constructor Detail

EncodedByteArrayConverterback to summary
public EncodedByteArrayConverter()

Constructs an EncodedByteArrayConverter. Initializes the converter with a Base64 codec.

EncodedByteArrayConverterback to summary
public EncodedByteArrayConverter(final StringCodec stringCodec)

Constructs an EncodedByteArrayConverter with a provided string codec.

Parameters
stringCodec:StringCodec

the codec to encode and decode the data as string

Since
1.4.11

Method Detail

canConvertback to summary
public boolean canConvert(Class<T> type)

Implements com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Doc from com.thoughtworks.xstream.converters.ConverterMatcher.canConvert.

Determines whether the converter can marshall a particular type.

Parameters
type:Class<T>

the Class representing the object type to be converted

fromStringback to summary
public Object fromString(final String str)

Implements com.thoughtworks.xstream.converters.SingleValueConverter.fromString.

Doc from com.thoughtworks.xstream.converters.SingleValueConverter.fromString.

Unmarshals an Object from its single value representation.

Parameters
str:String

the String with the single value of the Object

Returns:Object

the Object

marshalback to summary
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context)

Implements com.thoughtworks.xstream.converters.Converter.marshal.

Doc from com.thoughtworks.xstream.converters.Converter.marshal.

Convert an object to textual data.

Parameters
source:Object

The object to be marshalled.

writer:HierarchicalStreamWriter

A stream to write to.

context:MarshallingContext

A context that allows nested objects to be processed by XStream.

toStringback to summary
public String toString(final Object obj)

Implements com.thoughtworks.xstream.converters.SingleValueConverter.toString.

Doc from com.thoughtworks.xstream.converters.SingleValueConverter.toString.

Marshals an Object into a single value representation.

Parameters
obj:Object

the Object to be converted

Returns:String

a String with the single value of the Object or null

unmarshalback to summary
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)

Implements com.thoughtworks.xstream.converters.Converter.unmarshal.

Doc from com.thoughtworks.xstream.converters.Converter.unmarshal.

Convert textual data back into an object.

Parameters
reader:HierarchicalStreamReader

The stream to read the text from.

Returns:Object

The resulting object.

unmarshalIndividualByteElementsback to summary
private Object unmarshalIndividualByteElements(HierarchicalStreamReader reader, UnmarshallingContext context)