Top Description Inners Fields Constructors Methods
com.thoughtworks.xstream.converters.javabean

public Class JavaBeanConverter

extends Object
implements Converter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher
Imports
java.util.HashSet, .Set, com.thoughtworks.xstream.converters.ConversionException, .Converter, .MarshallingContext, .UnmarshallingContext, com.thoughtworks.xstream.converters.reflection.MissingFieldException, com.thoughtworks.xstream.core.util.FastField, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper, .HierarchicalStreamReader, .HierarchicalStreamWriter, com.thoughtworks.xstream.mapper.Mapper

Can convert any bean with a public default constructor. The BeanProvider used as default is based on java.beans.BeanInfo. Indexed properties are currently not supported.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
JavaBeanConverter.DuplicatePropertyException

Deprecated as a consequence of ConversionException being deprecated.
Exception to indicate double processing of a property to avoid silent clobbering.

Field Summary

Modifier and TypeField and Description
protected final JavaBeanProvider
private String
classAttributeIdentifier

Deprecated As of 1.3, no necessity for field anymore.
protected final Mapper
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
public
JavaBeanConverter(Mapper mapper, Class<T> type)

public
public
JavaBeanConverter(Mapper mapper, JavaBeanProvider beanProvider, Class<T> type)

public

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.

Checks if the bean provider can instantiate this type.
private Class<T>
private Object
public void
marshal(final Object
The object to be marshalled.
source
,
final HierarchicalStreamWriter
A stream to write to.
writer
,
final 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 Object
unmarshal(final HierarchicalStreamReader
The stream to read the text from.
reader
,
final UnmarshallingContext context)

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

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

Field Detail

beanProviderback to summary
protected final JavaBeanProvider beanProvider
classAttributeIdentifierback to summary
private String classAttributeIdentifier

Deprecated

As of 1.3, no necessity for field anymore.

mapperback to summary
protected final Mapper mapper
typeback to summary
private final Class<T> type

Constructor Detail

JavaBeanConverterback to summary
public JavaBeanConverter(Mapper mapper)
JavaBeanConverterback to summary
public JavaBeanConverter(Mapper mapper, Class<T> type)
JavaBeanConverterback to summary
public JavaBeanConverter(Mapper mapper, JavaBeanProvider beanProvider)
JavaBeanConverterback to summary
public JavaBeanConverter(Mapper mapper, JavaBeanProvider beanProvider, Class<T> type)
JavaBeanConverterback to summary
public JavaBeanConverter(Mapper mapper, String classAttributeIdentifier)

Method Detail

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

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

Checks if the bean provider can instantiate this type. If you need less strict checks, subclass JavaBeanConverter

Parameters
type:Class<T>

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

the Class representing the object type to be converted

determineTypeback to summary
private Class<T> determineType(HierarchicalStreamReader reader, Object result, String fieldName)
instantiateNewInstanceback to summary
private Object instantiateNewInstance(UnmarshallingContext context)
marshalback to summary
public void marshal(final Object source, final HierarchicalStreamWriter writer, final 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.

unmarshalback to summary
public Object unmarshal(final HierarchicalStreamReader reader, final 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.

com.thoughtworks.xstream.converters.javabean back to summary

public Class JavaBeanConverter.DuplicateFieldException

extends ConversionException
Class Inheritance

Deprecated

As of 1.3

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

DuplicateFieldExceptionback to summary
public DuplicateFieldException(String msg)
com.thoughtworks.xstream.converters.javabean back to summary

public Class JavaBeanConverter.DuplicatePropertyException

extends ConversionException
Class Inheritance

Deprecated

as a consequence of ConversionException being deprecated. See corresponding docs for further information.

Exception to indicate double processing of a property to avoid silent clobbering.
Author
Jörg Schaible
Since
1.4.2

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

DuplicatePropertyExceptionback to summary
public DuplicatePropertyException(String msg)