Package com.thoughtworks.xstream.mapper
Class AttributeMapper
- java.lang.Object
-
- com.thoughtworks.xstream.mapper.MapperWrapper
-
- com.thoughtworks.xstream.mapper.AttributeMapper
-
- All Implemented Interfaces:
Mapper
- Direct Known Subclasses:
UseAttributeForEnumMapper
public class AttributeMapper extends MapperWrapper
Mapper that allows the usage of attributes for fields and corresponding types or specified arbitrary types. It is responsible for the lookup of theSingleValueConverter
for item types and attribute names.- Since:
- 1.2
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
-
-
Field Summary
Fields Modifier and Type Field Description private ConverterLookup
converterLookup
private java.util.Map
fieldNameToTypeMap
private java.util.Set
fieldToUseAsAttribute
private ReflectionProvider
reflectionProvider
private java.util.Set
typeSet
-
Constructor Summary
Constructors Constructor Description AttributeMapper(Mapper wrapped)
Deprecated.As of 1.3AttributeMapper(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addAttributeFor(java.lang.Class type)
void
addAttributeFor(java.lang.Class definedIn, java.lang.String fieldName)
Tells this mapper to use an attribute for this field.void
addAttributeFor(java.lang.reflect.Field field)
Tells this mapper to use an attribute for this field.void
addAttributeFor(java.lang.String fieldName, java.lang.Class type)
SingleValueConverter
getConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute)
Deprecated.As of 1.3.1, usegetConverterFromAttribute(Class, String, Class)
SingleValueConverter
getConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute, java.lang.Class type)
Returns which converter to use for an specific attribute in a type.SingleValueConverter
getConverterFromAttribute(java.lang.String attributeName)
Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)
SingleValueConverter
getConverterFromItemType(java.lang.Class type)
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
SingleValueConverter
getConverterFromItemType(java.lang.String fieldName, java.lang.Class type)
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
SingleValueConverter
getConverterFromItemType(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
Returns a single value converter to be used in a specific field.private SingleValueConverter
getLocalConverterFromItemType(java.lang.Class type)
void
setConverterLookup(ConverterLookup converterLookup)
Deprecated.As of 1.3boolean
shouldLookForSingleValueConverter(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
-
Methods inherited from class com.thoughtworks.xstream.mapper.MapperWrapper
aliasForAttribute, aliasForAttribute, aliasForSystemAttribute, attributeForAlias, attributeForAlias, defaultImplementationOf, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, getLocalConverter, isIgnoredElement, isImmutableValueType, isReferenceable, lookupMapperOfType, realClass, realMember, serializedClass, serializedMember, shouldSerializeMember
-
-
-
-
Field Detail
-
fieldNameToTypeMap
private final java.util.Map fieldNameToTypeMap
-
typeSet
private final java.util.Set typeSet
-
converterLookup
private ConverterLookup converterLookup
-
reflectionProvider
private ReflectionProvider reflectionProvider
-
fieldToUseAsAttribute
private final java.util.Set fieldToUseAsAttribute
-
-
Constructor Detail
-
AttributeMapper
public AttributeMapper(Mapper wrapped)
Deprecated.As of 1.3
-
AttributeMapper
public AttributeMapper(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider)
-
-
Method Detail
-
setConverterLookup
public void setConverterLookup(ConverterLookup converterLookup)
Deprecated.As of 1.3
-
addAttributeFor
public void addAttributeFor(java.lang.String fieldName, java.lang.Class type)
-
addAttributeFor
public void addAttributeFor(java.lang.Class type)
-
getLocalConverterFromItemType
private SingleValueConverter getLocalConverterFromItemType(java.lang.Class type)
-
getConverterFromItemType
public SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type)
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in classMapperWrapper
-
getConverterFromItemType
public SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
Description copied from interface:Mapper
Returns a single value converter to be used in a specific field.- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in classMapperWrapper
- Parameters:
fieldName
- the field nametype
- the field typedefinedIn
- the type which defines this field- Returns:
- a SingleValueConverter or null if there no such converter should be used for this field.
-
shouldLookForSingleValueConverter
public boolean shouldLookForSingleValueConverter(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
-
getConverterFromItemType
public SingleValueConverter getConverterFromItemType(java.lang.Class type)
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in classMapperWrapper
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(java.lang.String attributeName)
Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)
- Specified by:
getConverterFromAttribute
in interfaceMapper
- Overrides:
getConverterFromAttribute
in classMapperWrapper
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute)
Deprecated.As of 1.3.1, usegetConverterFromAttribute(Class, String, Class)
Description copied from interface:Mapper
Returns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttribute
in interfaceMapper
- Overrides:
getConverterFromAttribute
in classMapperWrapper
- Parameters:
definedIn
- the field's parentattribute
- the attribute name
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute, java.lang.Class type)
Description copied from interface:Mapper
Returns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttribute
in interfaceMapper
- Overrides:
getConverterFromAttribute
in classMapperWrapper
- Parameters:
definedIn
- the field's parentattribute
- the attribute nametype
- the type the converter should create
-
addAttributeFor
public void addAttributeFor(java.lang.reflect.Field field)
Tells this mapper to use an attribute for this field.- Parameters:
field
- the field itself- Since:
- 1.2.2
-
addAttributeFor
public void addAttributeFor(java.lang.Class definedIn, java.lang.String fieldName)
Tells this mapper to use an attribute for this field.- Parameters:
definedIn
- the declaring class of the fieldfieldName
- the name of the field- Since:
- 1.3
-
-