Top Description Fields Constructors Methods
com.thoughtworks.xstream.mapper

public Class EnumMapper

extends MapperWrapper
implements Caching
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.core.Caching
Imports
com.thoughtworks.xstream.converters.ConverterLookup, .SingleValueConverter, com.thoughtworks.xstream.converters.enums.EnumSingleValueConverter, com.thoughtworks.xstream.core.Caching, java.util.EnumSet, .HashMap, .Map

Mapper that handles the special case of polymorphic enums in Java 1.5. This renames MyEnum$1 to MyEnum making it less bloaty in the XML and avoiding the need for an alias per enum value to be specified. Additionally every enum is treated automatically as immutable and non-refrenceable type that can be written as attribute.
Authors
Joe Walnes, Jörg Schaible

Field Summary

Modifier and TypeField and Description
private transient AttributeMapper
private transient Map<Class<T>, SingleValueConverter>

Constructor Summary

AccessConstructor and Description
public
EnumMapper(Mapper wrapped, ConverterLookup lookup)

Deprecated As of 1.3.1, use EnumMapper(Mapper)
public
EnumMapper(Mapper wrapped)

Method Summary

Modifier and TypeMethod and Description
public void
public SingleValueConverter
getConverterFromAttribute(Class<T>
the field's parent
definedIn
,
String
the attribute name
attribute
,
Class<T>
the type the converter should create
type
)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.
public SingleValueConverter
getConverterFromItemType(String
the field name
fieldName
,
Class<T>
the field type
type
,
Class<T>
the type which defines this field
definedIn
)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Returns a single value converter to be used in a specific field.
private SingleValueConverter
getLocalConverter(String fieldName, Class<T> type, Class<T> definedIn)

public boolean
isImmutableValueType(Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.isImmutableValueType.

Implements com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Whether this type is a simple immutable value (int, boolean, String, URL, etc).
public boolean
private Object
public String
serializedClass(Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass.

Implements com.thoughtworks.xstream.mapper.Mapper.serializedClass.

How a class name should be represented in its serialized form.
Inherited from com.thoughtworks.xstream.mapper.MapperWrapper:
aliasForAttributealiasForAttributealiasForSystemAttributeattributeForAliasattributeForAliasdefaultImplementationOfgetConverterFromAttributegetConverterFromAttributegetConverterFromItemTypegetConverterFromItemTypegetFieldNameForItemTypeAndNamegetImplicitCollectionDefForFieldNamegetItemTypeForItemFieldNamegetLocalConverterisIgnoredElementlookupMapperOfTyperealClassrealMemberserializedMembershouldSerializeMember

Field Detail

attributeMapperback to summary
private transient AttributeMapper attributeMapper
enumConverterMapback to summary
private transient Map<Class<T>, SingleValueConverter> enumConverterMap

Constructor Detail

EnumMapperback to summary
public EnumMapper(Mapper wrapped, ConverterLookup lookup)

Deprecated

As of 1.3.1, use EnumMapper(Mapper)

Annotations
@Deprecated
EnumMapperback to summary
public EnumMapper(Mapper wrapped)

Method Detail

flushCacheback to summary
public void flushCache()

Implements com.thoughtworks.xstream.core.Caching.flushCache.

getConverterFromAttributeback to summary
public SingleValueConverter getConverterFromAttribute(Class<T> definedIn, String attribute, Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromAttribute.

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Doc from com.thoughtworks.xstream.mapper.Mapper.getConverterFromAttribute.

Returns which converter to use for an specific attribute in a type.

Parameters
definedIn:Class<T>

the field's parent

attribute:String

the attribute name

type:Class<T>

the type the converter should create

Annotations
@Override
getConverterFromItemTypeback to summary
public SingleValueConverter getConverterFromItemType(String fieldName, Class<T> type, Class<T> definedIn)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.getConverterFromItemType.

Implements com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Doc from com.thoughtworks.xstream.mapper.Mapper.getConverterFromItemType.

Returns a single value converter to be used in a specific field.

Parameters
fieldName:String

the field name

type:Class<T>

the field type

definedIn:Class<T>

the type which defines this field

Returns:SingleValueConverter

a SingleValueConverter or null if there no such converter should be used for this field.

Annotations
@Override
getLocalConverterback to summary
private SingleValueConverter getLocalConverter(String fieldName, Class<T> type, Class<T> definedIn)
isImmutableValueTypeback to summary
public boolean isImmutableValueType(Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.isImmutableValueType.

Implements com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Doc from com.thoughtworks.xstream.mapper.Mapper.isImmutableValueType.

Whether this type is a simple immutable value (int, boolean, String, URL, etc). Immutable types will be repeatedly written in the serialized stream, instead of using object references.

Annotations
@Override
isReferenceableback to summary
public boolean isReferenceable(final Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.isReferenceable.

Implements com.thoughtworks.xstream.mapper.Mapper.isReferenceable.

Doc from com.thoughtworks.xstream.mapper.Mapper.isReferenceable.

Whether this type is referenceable in a stream.

Annotations
@Override
readResolveback to summary
private Object readResolve()
serializedClassback to summary
public String serializedClass(Class<T> type)

Overrides com.thoughtworks.xstream.mapper.MapperWrapper.serializedClass.

Implements com.thoughtworks.xstream.mapper.Mapper.serializedClass.

Doc from com.thoughtworks.xstream.mapper.Mapper.serializedClass.

How a class name should be represented in its serialized form.

Annotations
@Override