Package com.thoughtworks.xstream.mapper
Class EnumMapper
- java.lang.Object
-
- com.thoughtworks.xstream.mapper.MapperWrapper
-
- com.thoughtworks.xstream.mapper.EnumMapper
-
public class EnumMapper extends MapperWrapper implements Caching
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
-
-
Field Summary
Fields Modifier and Type Field Description private AttributeMapperattributeMapperprivate java.util.Map<java.lang.Class,SingleValueConverter>enumConverterMap
-
Constructor Summary
Constructors Constructor Description EnumMapper(Mapper wrapped)EnumMapper(Mapper wrapped, ConverterLookup lookup)Deprecated.As of 1.3.1, useEnumMapper(Mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflushCache()SingleValueConvertergetConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute, java.lang.Class type)Returns which converter to use for an specific attribute in a type.SingleValueConvertergetConverterFromItemType(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)Returns a single value converter to be used in a specific field.private SingleValueConvertergetLocalConverter(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)booleanisImmutableValueType(java.lang.Class type)Whether this type is a simple immutable value (int, boolean, String, URL, etc).booleanisReferenceable(java.lang.Class type)Whether this type is referenceable in a stream.private java.lang.ObjectreadResolve()java.lang.StringserializedClass(java.lang.Class type)How a class name should be represented in its serialized form.-
Methods inherited from class com.thoughtworks.xstream.mapper.MapperWrapper
aliasForAttribute, aliasForAttribute, aliasForSystemAttribute, attributeForAlias, attributeForAlias, defaultImplementationOf, getConverterFromAttribute, getConverterFromAttribute, getConverterFromItemType, getConverterFromItemType, getFieldNameForItemTypeAndName, getImplicitCollectionDefForFieldName, getItemTypeForItemFieldName, getLocalConverter, isIgnoredElement, lookupMapperOfType, realClass, realMember, serializedMember, shouldSerializeMember
-
-
-
-
Field Detail
-
attributeMapper
private transient AttributeMapper attributeMapper
-
enumConverterMap
private transient java.util.Map<java.lang.Class,SingleValueConverter> enumConverterMap
-
-
Constructor Detail
-
EnumMapper
@Deprecated public EnumMapper(Mapper wrapped, ConverterLookup lookup)
Deprecated.As of 1.3.1, useEnumMapper(Mapper)
-
EnumMapper
public EnumMapper(Mapper wrapped)
-
-
Method Detail
-
serializedClass
public java.lang.String serializedClass(java.lang.Class type)
Description copied from interface:MapperHow a class name should be represented in its serialized form.- Specified by:
serializedClassin interfaceMapper- Overrides:
serializedClassin classMapperWrapper
-
isImmutableValueType
public boolean isImmutableValueType(java.lang.Class type)
Description copied from interface:MapperWhether 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:
isImmutableValueTypein interfaceMapper- Overrides:
isImmutableValueTypein classMapperWrapper
-
isReferenceable
public boolean isReferenceable(java.lang.Class type)
Description copied from interface:MapperWhether this type is referenceable in a stream.- Specified by:
isReferenceablein interfaceMapper- Overrides:
isReferenceablein classMapperWrapper
-
getConverterFromItemType
public SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
Description copied from interface:MapperReturns a single value converter to be used in a specific field.- Specified by:
getConverterFromItemTypein interfaceMapper- Overrides:
getConverterFromItemTypein 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.
-
getConverterFromAttribute
public SingleValueConverter getConverterFromAttribute(java.lang.Class definedIn, java.lang.String attribute, java.lang.Class type)
Description copied from interface:MapperReturns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttributein interfaceMapper- Overrides:
getConverterFromAttributein classMapperWrapper- Parameters:
definedIn- the field's parentattribute- the attribute nametype- the type the converter should create
-
getLocalConverter
private SingleValueConverter getLocalConverter(java.lang.String fieldName, java.lang.Class type, java.lang.Class definedIn)
-
flushCache
public void flushCache()
- Specified by:
flushCachein interfaceCaching
-
readResolve
private java.lang.Object readResolve()
-
-