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

public Class AttributeMapper

extends MapperWrapper
Class Inheritance
Known Direct Subclasses
com.thoughtworks.xstream.converters.extended.UseAttributeForEnumMapper
Imports
java.lang.reflect.Field, java.util.HashMap, .HashSet, .Map, .Set, com.thoughtworks.xstream.converters.Converter, .ConverterLookup, .SingleValueConverter, com.thoughtworks.xstream.converters.reflection.ReflectionProvider

Mapper that allows the usage of attributes for fields and corresponding types or specified arbitrary types. It is responsible for the lookup of the SingleValueConverter for item types and attribute names.
Authors
Paul Hammant, Ian Cartwright, Jörg Schaible, Mauro Talevi, Guilherme Silveira
Since
1.2

Field Summary

Modifier and TypeField and Description
private ConverterLookup
private final Map<K, V>
private final Set<E>
private ReflectionProvider
private final Set<E>

Constructor Summary

AccessConstructor and Description
public
AttributeMapper(Mapper wrapped)

Deprecated As of 1.3
public
AttributeMapper(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider)

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeFor(final String fieldName, final Class<T> type)

public void
addAttributeFor(final Class<T> type)

public void
addAttributeFor(final Field
the field itself
field
)

Tells this mapper to use an attribute for this field.

public void
addAttributeFor(Class<T>
the declaring class of the field
definedIn
,
String
the name of the field
fieldName
)

Tells this mapper to use an attribute for this field.

public SingleValueConverter
public SingleValueConverter
getConverterFromAttribute(Class<T>
the field's parent
definedIn
,
String
the attribute name
attribute
)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

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
)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

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

Returns which converter to use for an specific attribute in a type.
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
)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

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

Returns a single value converter to be used in a specific field.
public SingleValueConverter
private SingleValueConverter
public void
setConverterLookup(ConverterLookup converterLookup)

Deprecated As of 1.3
public boolean
shouldLookForSingleValueConverter(String fieldName, Class<T> type, Class<T> definedIn)

Inherited from com.thoughtworks.xstream.mapper.MapperWrapper:
aliasForAttributealiasForAttributealiasForSystemAttributeattributeForAliasattributeForAliasdefaultImplementationOfgetFieldNameForItemTypeAndNamegetImplicitCollectionDefForFieldNamegetItemTypeForItemFieldNamegetLocalConverterisIgnoredElementisImmutableValueTypeisReferenceablelookupMapperOfTyperealClassrealMemberserializedClassserializedMembershouldSerializeMember

Field Detail

converterLookupback to summary
private ConverterLookup converterLookup
fieldNameToTypeMapback to summary
private final Map<K, V> fieldNameToTypeMap
fieldToUseAsAttributeback to summary
private final Set<E> fieldToUseAsAttribute
reflectionProviderback to summary
private ReflectionProvider reflectionProvider
typeSetback to summary
private final Set<E> typeSet

Constructor Detail

AttributeMapperback to summary
public AttributeMapper(Mapper wrapped)

Deprecated

As of 1.3

AttributeMapperback to summary
public AttributeMapper(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider)

Method Detail

addAttributeForback to summary
public void addAttributeFor(final String fieldName, final Class<T> type)
addAttributeForback to summary
public void addAttributeFor(final Class<T> type)
addAttributeForback to summary
public void addAttributeFor(final Field field)

Tells this mapper to use an attribute for this field.

Parameters
field:Field

the field itself

Since
1.2.2
addAttributeForback to summary
public void addAttributeFor(Class<T> definedIn, String fieldName)

Tells this mapper to use an attribute for this field.

Parameters
definedIn:Class<T>

the declaring class of the field

fieldName:String

the name of the field

Since
1.3
getConverterFromAttributeback to summary
public SingleValueConverter getConverterFromAttribute(String attributeName)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

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

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

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

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)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

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)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

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

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

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

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.

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

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

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

getLocalConverterFromItemTypeback to summary
private SingleValueConverter getLocalConverterFromItemType(Class<T> type)
setConverterLookupback to summary
public void setConverterLookup(ConverterLookup converterLookup)

Deprecated

As of 1.3

shouldLookForSingleValueConverterback to summary
public boolean shouldLookForSingleValueConverter(String fieldName, Class<T> type, Class<T> definedIn)