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
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.- Since:
- 1.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ConverterLookup
private final Map
private final Set
private ReflectionProvider
private final Set
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeMapper
(Mapper wrapped) Deprecated.As of 1.3AttributeMapper
(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttributeFor
(Class type) void
addAttributeFor
(Class definedIn, String fieldName) Tells this mapper to use an attribute for this field.void
addAttributeFor
(Field field) Tells this mapper to use an attribute for this field.void
addAttributeFor
(String fieldName, Class type) getConverterFromAttribute
(Class definedIn, String attribute) Deprecated.As of 1.3.1, usegetConverterFromAttribute(Class, String, Class)
getConverterFromAttribute
(Class definedIn, String attribute, Class type) Returns which converter to use for an specific attribute in a type.getConverterFromAttribute
(String attributeName) Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
getConverterFromItemType
(String fieldName, Class type) Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
getConverterFromItemType
(String fieldName, Class type, Class definedIn) Returns a single value converter to be used in a specific field.private SingleValueConverter
void
setConverterLookup
(ConverterLookup converterLookup) Deprecated.As of 1.3boolean
shouldLookForSingleValueConverter
(String fieldName, Class type, 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 Details
-
fieldNameToTypeMap
-
typeSet
-
converterLookup
-
reflectionProvider
-
fieldToUseAsAttribute
-
-
Constructor Details
-
AttributeMapper
Deprecated.As of 1.3 -
AttributeMapper
public AttributeMapper(Mapper wrapped, ConverterLookup converterLookup, ReflectionProvider refProvider)
-
-
Method Details
-
setConverterLookup
Deprecated.As of 1.3 -
addAttributeFor
-
addAttributeFor
-
getLocalConverterFromItemType
-
getConverterFromItemType
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in classMapperWrapper
-
getConverterFromItemType
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
-
getConverterFromItemType
Deprecated.As of 1.3, usegetConverterFromItemType(String, Class, Class)
- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in classMapperWrapper
-
getConverterFromAttribute
Deprecated.As of 1.3, usegetConverterFromAttribute(Class, String, Class)
- Specified by:
getConverterFromAttribute
in interfaceMapper
- Overrides:
getConverterFromAttribute
in classMapperWrapper
-
getConverterFromAttribute
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(Class definedIn, String attribute, 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
Tells this mapper to use an attribute for this field.- Parameters:
field
- the field itself- Since:
- 1.2.2
-
addAttributeFor
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
-