com.thoughtworks.xstream.mapper
Class EnumMapper

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

public class EnumMapper
extends AttributeMapper

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 type and can be written as attribute.

Author:
Joe Walnes, Jörg Schaible

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
 
Constructor Summary
EnumMapper(ClassMapper wrapped)
          Deprecated. since 1.2, use #EnumMapper(Mapper, ConverterLookup))
EnumMapper(Mapper wrapped)
          Deprecated. since 1.3, use EnumMapper(Mapper, ConverterLookup)
EnumMapper(Mapper wrapped, ConverterLookup converterLookup)
           
 
Method Summary
protected  SingleValueConverter getLocalConverterFromItemType(java.lang.Class type)
           
 boolean isImmutableValueType(java.lang.Class type)
          Whether this type is a simple immutable value (int, boolean, String, URL, etc.
 java.lang.String serializedClass(java.lang.Class type)
          How a class name should be represented in its serialized form.
 
Methods inherited from class com.thoughtworks.xstream.mapper.AttributeMapper
addAttributeFor, addAttributeFor, addAttributeFor, addAttributeFor, getConverterFromAttribute, getConverterFromAttribute, getConverterFromItemType, getConverterFromItemType, getConverterFromItemType, setConverterLookup
 
Methods inherited from class com.thoughtworks.xstream.mapper.MapperWrapper
aliasForAttribute, aliasForAttribute, attributeForAlias, attributeForAlias, attributeForClassDefiningField, attributeForEnumType, attributeForImplementationClass, attributeForReadResolveField, defaultImplementationOf, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, getLocalConverter, lookupMapperOfType, realClass, realMember, serializedMember, shouldSerializeMember
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumMapper

public EnumMapper(Mapper wrapped,
                  ConverterLookup converterLookup)

EnumMapper

@Deprecated
public EnumMapper(Mapper wrapped)
Deprecated. since 1.3, use EnumMapper(Mapper, ConverterLookup)


EnumMapper

@Deprecated
public EnumMapper(ClassMapper wrapped)
Deprecated. since 1.2, use #EnumMapper(Mapper, ConverterLookup))

Method Detail

serializedClass

public java.lang.String serializedClass(java.lang.Class type)
Description copied from interface: Mapper
How a class name should be represented in its serialized form.

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

isImmutableValueType

public boolean isImmutableValueType(java.lang.Class type)
Description copied from interface: Mapper
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.

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

getLocalConverterFromItemType

protected SingleValueConverter getLocalConverterFromItemType(java.lang.Class type)
Overrides:
getLocalConverterFromItemType in class AttributeMapper


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