com.thoughtworks.xstream.mapper
Class AttributeMapper

java.lang.Object
  extended by com.thoughtworks.xstream.mapper.MapperWrapper
      extended by com.thoughtworks.xstream.mapper.AttributeMapper
All Implemented Interfaces:
Mapper

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 the SingleValueConverter for item types and attribute names.

Since:
1.2
Author:
Paul Hammant, Ian Cartwright, Jörg Schaible, Mauro Talevi, Guilherme Silveira

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
 
Constructor Summary
AttributeMapper(Mapper wrapped)
          Deprecated. since 1.3
AttributeMapper(Mapper wrapped, ConverterLookup converterLookup)
           
 
Method Summary
 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. since 1.3.1, use getConverterFromAttribute(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. since 1.3, use getConverterFromAttribute(Class, String, Class)
 SingleValueConverter getConverterFromItemType(java.lang.Class type)
          Deprecated. since 1.3, use getConverterFromItemType(String, Class, Class)
 SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type)
          Deprecated. since 1.3, use getConverterFromItemType(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.
 void setConverterLookup(ConverterLookup converterLookup)
          Deprecated. since 1.3
 boolean 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, attributeForClassDefiningField, attributeForEnumType, attributeForImplementationClass, attributeForReadResolveField, defaultImplementationOf, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, getLocalConverter, isImmutableValueType, lookupMapperOfType, realClass, realMember, serializedClass, serializedMember, shouldSerializeMember
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeMapper

public AttributeMapper(Mapper wrapped)
Deprecated. since 1.3


AttributeMapper

public AttributeMapper(Mapper wrapped,
                       ConverterLookup converterLookup)
Method Detail

setConverterLookup

public void setConverterLookup(ConverterLookup converterLookup)
Deprecated. since 1.3


addAttributeFor

public void addAttributeFor(java.lang.String fieldName,
                            java.lang.Class type)

addAttributeFor

public void addAttributeFor(java.lang.Class type)

getConverterFromItemType

public SingleValueConverter getConverterFromItemType(java.lang.String fieldName,
                                                     java.lang.Class type)
Deprecated. since 1.3, use getConverterFromItemType(String, Class, Class)

Specified by:
getConverterFromItemType in interface Mapper
Overrides:
getConverterFromItemType in class MapperWrapper

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 interface Mapper
Overrides:
getConverterFromItemType in class MapperWrapper
Parameters:
fieldName - the field name
type - the field type
definedIn - 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. since 1.3, use getConverterFromItemType(String, Class, Class)

Specified by:
getConverterFromItemType in interface Mapper
Overrides:
getConverterFromItemType in class MapperWrapper

getConverterFromAttribute

public SingleValueConverter getConverterFromAttribute(java.lang.String attributeName)
Deprecated. since 1.3, use getConverterFromAttribute(Class, String, Class)

Specified by:
getConverterFromAttribute in interface Mapper
Overrides:
getConverterFromAttribute in class MapperWrapper

getConverterFromAttribute

public SingleValueConverter getConverterFromAttribute(java.lang.Class definedIn,
                                                      java.lang.String attribute)
Deprecated. since 1.3.1, use getConverterFromAttribute(Class, String, Class)

Description copied from interface: Mapper
Returns which converter to use for an specific attribute in a type.

Specified by:
getConverterFromAttribute in interface Mapper
Overrides:
getConverterFromAttribute in class MapperWrapper
Parameters:
definedIn - the field's parent
attribute - 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 interface Mapper
Overrides:
getConverterFromAttribute in class MapperWrapper
Parameters:
definedIn - the field's parent
attribute - the attribute name
type - 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 field
fieldName - the name of the field
Throws:
java.lang.IllegalArgumentException - if the field does not exist
Since:
1.3


Copyright © 2004-2012 XStream. All Rights Reserved.