com.thoughtworks.xstream.mapper
Class AttributeMapper

java.lang.Object
  extended bycom.thoughtworks.xstream.mapper.MapperWrapper
      extended bycom.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 inherited from class com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
 
Constructor Summary
AttributeMapper(Mapper wrapped)
           
AttributeMapper(Mapper wrapped, ConverterLookup converterLookup)
           
 
Method Summary
 void addAttributeFor(java.lang.Class type)
           
 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 type, java.lang.String attribute)
          Returns which converter to use for an specific attribute in a type.
 SingleValueConverter getConverterFromAttribute(java.lang.String attributeName)
           
 SingleValueConverter getConverterFromItemType(java.lang.Class type)
           
 SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type)
           
 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.
protected  SingleValueConverter getLocalConverterFromItemType(java.lang.Class type)
           
 void setConverterLookup(ConverterLookup converterLookup)
           
 
Methods inherited from class com.thoughtworks.xstream.mapper.MapperWrapper
aliasForAttribute, aliasForAttribute, attributeForAlias, attributeForAlias, attributeForClassDefiningField, attributeForEnumType, attributeForImplementationClass, attributeForReadResolveField, defaultImplementationOf, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, 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)

AttributeMapper

public AttributeMapper(Mapper wrapped,
                       ConverterLookup converterLookup)
Method Detail

setConverterLookup

public void setConverterLookup(ConverterLookup converterLookup)

addAttributeFor

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

addAttributeFor

public void addAttributeFor(java.lang.Class type)

getLocalConverterFromItemType

protected SingleValueConverter getLocalConverterFromItemType(java.lang.Class type)

getConverterFromItemType

public SingleValueConverter getConverterFromItemType(java.lang.String fieldName,
                                                     java.lang.Class type)
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

getConverterFromItemType

public SingleValueConverter getConverterFromItemType(java.lang.Class type)
Specified by:
getConverterFromItemType in interface Mapper
Overrides:
getConverterFromItemType in class MapperWrapper

getConverterFromAttribute

public SingleValueConverter getConverterFromAttribute(java.lang.String attributeName)
Specified by:
getConverterFromAttribute in interface Mapper
Overrides:
getConverterFromAttribute in class MapperWrapper

getConverterFromAttribute

public SingleValueConverter getConverterFromAttribute(java.lang.Class type,
                                                      java.lang.String attribute)
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

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


Joe Walnes, http://xstream.codehaus.org/