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 theSingleValueConverterfor 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 ConverterLookupconverterLookupprivate java.util.MapfieldNameToTypeMapprivate java.util.SetfieldToUseAsAttributeprivate ReflectionProviderreflectionProviderprivate java.util.SettypeSet
-
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 voidaddAttributeFor(java.lang.Class type)voidaddAttributeFor(java.lang.Class definedIn, java.lang.String fieldName)Tells this mapper to use an attribute for this field.voidaddAttributeFor(java.lang.reflect.Field field)Tells this mapper to use an attribute for this field.voidaddAttributeFor(java.lang.String fieldName, java.lang.Class type)SingleValueConvertergetConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute)Deprecated.As of 1.3.1, usegetConverterFromAttribute(Class, String, Class)SingleValueConvertergetConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute, java.lang.Class type)Returns which converter to use for an specific attribute in a type.SingleValueConvertergetConverterFromAttribute(java.lang.String attributeName)Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)SingleValueConvertergetConverterFromItemType(java.lang.Class type)Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)SingleValueConvertergetConverterFromItemType(java.lang.String fieldName, java.lang.Class type)Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)SingleValueConvertergetConverterFromItemType(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 SingleValueConvertergetLocalConverterFromItemType(java.lang.Class type)voidsetConverterLookup(ConverterLookup converterLookup)Deprecated.As of 1.3booleanshouldLookForSingleValueConverter(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:
getConverterFromItemTypein interfaceMapper- Overrides:
getConverterFromItemTypein classMapperWrapper
-
getConverterFromItemType
public SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
Description copied from interface:MapperReturns a single value converter to be used in a specific field.- Specified by:
getConverterFromItemTypein interfaceMapper- Overrides:
getConverterFromItemTypein 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:
getConverterFromItemTypein interfaceMapper- Overrides:
getConverterFromItemTypein classMapperWrapper
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(java.lang.String attributeName)
Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)- Specified by:
getConverterFromAttributein interfaceMapper- Overrides:
getConverterFromAttributein 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:MapperReturns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttributein interfaceMapper- Overrides:
getConverterFromAttributein 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:MapperReturns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttributein interfaceMapper- Overrides:
getConverterFromAttributein 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
-
-