Top Description Fields Constructors Methods
com.thoughtworks.xstream.mapper

public Class DefaultMapper

extends Object
implements Mapper
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.mapper.Mapper
Imports
com.thoughtworks.xstream.converters.Converter, .SingleValueConverter, com.thoughtworks.xstream.core.ClassLoaderReference, com.thoughtworks.xstream.core.util.Primitives

Default mapper implementation with 'vanilla' functionality.

To build up the functionality required, wrap this mapper with other mapper implementations.

Authors
Joe Walnes, Jörg Schaible

Field Summary

Modifier and TypeField and Description
private final ClassLoaderReference
private static String

Constructor Summary

AccessConstructor and Description
public
DefaultMapper(ClassLoaderReference
the reference to the classloader used by the XStream instance.
classLoaderReference
)

Construct a DefaultMapper.

public
DefaultMapper(ClassLoader
the ClassLoader used by the XStream instance.
classLoader
)

Deprecated As of 1.4.5 use DefaultMapper(ClassLoaderReference)
Construct a DefaultMapper.

Method Summary

Modifier and TypeMethod and Description
public String
aliasForAttribute(String
the attribute
attribute
)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Get the alias for an attribute's name.
public String
aliasForAttribute(Class<T>
the type where the field was defined
definedIn
,
String
the field name
fieldName
)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Returns an alias for a single field defined in an specific type.
public String
aliasForSystemAttribute(String
the system attribute
attribute
)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForSystemAttribute.

Get the alias for a system attribute's name.
public String
attributeForAlias(String
the alias
alias
)

Implements com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Get the attribute's name for an alias.
public String
attributeForAlias(Class<T>
the type where the field was defined
definedIn
,
String
the alias
alias
)

Implements com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Deprecated As of 1.3, use combination of realMember(Class, String) and getConverterFromItemType(String, Class, Class)
Returns the field name for an aliased attribute.
public Class<T>
public SingleValueConverter
public SingleValueConverter
getConverterFromAttribute(Class<T>
the field's parent
definedIn
,
String
the attribute name
attribute
)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.
public SingleValueConverter
getConverterFromAttribute(Class<T>
the field's parent
definedIn
,
String
the attribute name
attribute
,
Class<T>
the type the converter should create
type
)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.
public SingleValueConverter
public SingleValueConverter
public SingleValueConverter
getConverterFromItemType(String
the field name
fieldName
,
Class<T>
the field type
type
,
Class<T>
the type which defines this field
definedIn
)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Returns a single value converter to be used in a specific field.
public String
getFieldNameForItemTypeAndName(Class<T>
owning type
definedIn
,
Class<T>
item type
itemType
,
String
optional item element name
itemFieldName
)

Implements com.thoughtworks.xstream.mapper.Mapper.getFieldNameForItemTypeAndName.

Get the name of the field that acts as the default collection for an object, or return null if there is none.
public Mapper.ImplicitCollectionMapping
public Class<T>
public Converter
public boolean
isIgnoredElement(String name)

Implements com.thoughtworks.xstream.mapper.Mapper.isIgnoredElement.

Whether this name can be ignored.
public boolean
isImmutableValueType(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Whether this type is a simple immutable value (int, boolean, String, URL, etc).
public boolean
isReferenceable(final Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.isReferenceable.

Whether this type is referenceable in a stream.
public Mapper
public String
lookupName(Class<T> type)

public Class<T>
lookupType(String elementName)

public Class<T>
realClass(String elementName)

Implements com.thoughtworks.xstream.mapper.Mapper.realClass.

How a serialized class representation should be mapped back to a real class.
public String
realMember(Class<T> type, String serialized)

Implements com.thoughtworks.xstream.mapper.Mapper.realMember.

How a serialized member representation should be mapped back to a real member.
public String
serializedClass(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.serializedClass.

How a class name should be represented in its serialized form.
public String
serializedMember(Class<T> type, String memberName)

Implements com.thoughtworks.xstream.mapper.Mapper.serializedMember.

How a class member should be represented in its serialized form.
public boolean
shouldSerializeMember(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.shouldSerializeMember.

Determine whether a specific member should be serialized.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderReferenceback to summary
private final ClassLoaderReference classLoaderReference
XSTREAM_PACKAGE_ROOTback to summary
private static String XSTREAM_PACKAGE_ROOT

Constructor Detail

DefaultMapperback to summary
public DefaultMapper(ClassLoaderReference classLoaderReference)

Construct a DefaultMapper.

Parameters
classLoaderReference:ClassLoaderReference

the reference to the classloader used by the XStream instance.

Since
1.4.5
DefaultMapperback to summary
public DefaultMapper(ClassLoader classLoader)

Deprecated

As of 1.4.5 use DefaultMapper(ClassLoaderReference)

Construct a DefaultMapper.

Parameters
classLoader:ClassLoader

the ClassLoader used by the XStream instance.

Method Detail

aliasForAttributeback to summary
public String aliasForAttribute(String attribute)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Get the alias for an attribute's name.

Parameters
attribute:String

the attribute

Returns:String

the alias

aliasForAttributeback to summary
public String aliasForAttribute(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.aliasForAttribute.

Returns an alias for a single field defined in an specific type.

Parameters
definedIn:Class<T>

the type where the field was defined

fieldName:String

the field name

Returns:String

the alias for this field or its own name if no alias was defined

aliasForSystemAttributeback to summary
public String aliasForSystemAttribute(String attribute)

Implements com.thoughtworks.xstream.mapper.Mapper.aliasForSystemAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.aliasForSystemAttribute.

Get the alias for a system attribute's name.

Parameters
attribute:String

the system attribute

Returns:String

the alias

attributeForAliasback to summary
public String attributeForAlias(String alias)

Implements com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Doc from com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Get the attribute's name for an alias.

Parameters
alias:String

the alias

Returns:String

the attribute's name

attributeForAliasback to summary
public String attributeForAlias(Class<T> definedIn, String alias)

Implements com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Doc from com.thoughtworks.xstream.mapper.Mapper.attributeForAlias.

Returns the field name for an aliased attribute.

Parameters
definedIn:Class<T>

the type where the field was defined

alias:String

the alias

Returns:String

the original attribute name

defaultImplementationOfback to summary
public Class<T> defaultImplementationOf(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.defaultImplementationOf.

getConverterFromAttributeback to summary
public SingleValueConverter getConverterFromAttribute(String name)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

getConverterFromAttributeback to summary
public SingleValueConverter getConverterFromAttribute(Class<T> definedIn, String attribute)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.

Parameters
definedIn:Class<T>

the field's parent

attribute:String

the attribute name

getConverterFromAttributeback to summary
public SingleValueConverter getConverterFromAttribute(Class<T> definedIn, String attribute, Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.

Parameters
definedIn:Class<T>

the field's parent

attribute:String

the attribute name

type:Class<T>

the type the converter should create

getConverterFromItemTypeback to summary
public SingleValueConverter getConverterFromItemType(String fieldName, Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

getConverterFromItemTypeback to summary
public SingleValueConverter getConverterFromItemType(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

getConverterFromItemTypeback to summary
public SingleValueConverter getConverterFromItemType(String fieldName, Class<T> type, Class<T> definedIn)

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Doc from com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Returns a single value converter to be used in a specific field.

Parameters
fieldName:String

the field name

type:Class<T>

the field type

definedIn:Class<T>

the type which defines this field

Returns:SingleValueConverter

a SingleValueConverter or null if there no such converter should be used for this field.

getFieldNameForItemTypeAndNameback to summary
public String getFieldNameForItemTypeAndName(Class<T> definedIn, Class<T> itemType, String itemFieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.getFieldNameForItemTypeAndName.

Doc from com.thoughtworks.xstream.mapper.Mapper.getFieldNameForItemTypeAndName.

Get the name of the field that acts as the default collection for an object, or return null if there is none.

Parameters
definedIn:Class<T>

owning type

itemType:Class<T>

item type

itemFieldName:String

optional item element name

getImplicitCollectionDefForFieldNameback to summary
public Mapper.ImplicitCollectionMapping getImplicitCollectionDefForFieldName(Class<T> itemType, String fieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.getImplicitCollectionDefForFieldName.

getItemTypeForItemFieldNameback to summary
public Class<T> getItemTypeForItemFieldName(Class<T> definedIn, String itemFieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.getItemTypeForItemFieldName.

getLocalConverterback to summary
public Converter getLocalConverter(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.getLocalConverter.

isIgnoredElementback to summary
public boolean isIgnoredElement(String name)

Implements com.thoughtworks.xstream.mapper.Mapper.isIgnoredElement.

Doc from com.thoughtworks.xstream.mapper.Mapper.isIgnoredElement.

Whether this name can be ignored.

isImmutableValueTypeback to summary
public boolean isImmutableValueType(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Doc from com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Whether this type is a simple immutable value (int, boolean, String, URL, etc). Immutable types will be repeatedly written in the serialized stream, instead of using object references.

isReferenceableback to summary
public boolean isReferenceable(final Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.isReferenceable.

Doc from com.thoughtworks.xstream.mapper.Mapper.isReferenceable.

Whether this type is referenceable in a stream.

lookupMapperOfTypeback to summary
public Mapper lookupMapperOfType(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.lookupMapperOfType.

lookupNameback to summary
public String lookupName(Class<T> type)
lookupTypeback to summary
public Class<T> lookupType(String elementName)
realClassback to summary
public Class<T> realClass(String elementName)

Implements com.thoughtworks.xstream.mapper.Mapper.realClass.

Doc from com.thoughtworks.xstream.mapper.Mapper.realClass.

How a serialized class representation should be mapped back to a real class.

realMemberback to summary
public String realMember(Class<T> type, String serialized)

Implements com.thoughtworks.xstream.mapper.Mapper.realMember.

Doc from com.thoughtworks.xstream.mapper.Mapper.realMember.

How a serialized member representation should be mapped back to a real member.

serializedClassback to summary
public String serializedClass(Class<T> type)

Implements com.thoughtworks.xstream.mapper.Mapper.serializedClass.

Doc from com.thoughtworks.xstream.mapper.Mapper.serializedClass.

How a class name should be represented in its serialized form.

serializedMemberback to summary
public String serializedMember(Class<T> type, String memberName)

Implements com.thoughtworks.xstream.mapper.Mapper.serializedMember.

Doc from com.thoughtworks.xstream.mapper.Mapper.serializedMember.

How a class member should be represented in its serialized form.

shouldSerializeMemberback to summary
public boolean shouldSerializeMember(Class<T> definedIn, String fieldName)

Implements com.thoughtworks.xstream.mapper.Mapper.shouldSerializeMember.

Doc from com.thoughtworks.xstream.mapper.Mapper.shouldSerializeMember.

Determine whether a specific member should be serialized.