Package com.thoughtworks.xstream.mapper
Class EnumMapper
java.lang.Object
com.thoughtworks.xstream.mapper.MapperWrapper
com.thoughtworks.xstream.mapper.EnumMapper
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 -
Constructor Summary
ConstructorsConstructorDescriptionEnumMapper
(Mapper wrapped) EnumMapper
(Mapper wrapped, ConverterLookup lookup) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
getConverterFromAttribute
(Class definedIn, String attribute, Class type) Returns which converter to use for an specific attribute in a type.getConverterFromItemType
(String fieldName, Class type, Class definedIn) Returns a single value converter to be used in a specific field.private SingleValueConverter
getLocalConverter
(String fieldName, Class type, Class definedIn) boolean
isImmutableValueType
(Class type) Whether this type is a simple immutable value (int, boolean, String, URL, etc).boolean
isReferenceable
(Class type) Whether this type is referenceable in a stream.private Object
serializedClass
(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 Details
-
attributeMapper
-
enumConverterMap
-
-
Constructor Details
-
EnumMapper
Deprecated.As of 1.3.1, useEnumMapper(Mapper)
-
EnumMapper
-
-
Method Details
-
serializedClass
Description copied from interface:Mapper
How a class name should be represented in its serialized form.- Specified by:
serializedClass
in interfaceMapper
- Overrides:
serializedClass
in classMapperWrapper
-
isImmutableValueType
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 interfaceMapper
- Overrides:
isImmutableValueType
in classMapperWrapper
-
isReferenceable
Description copied from interface:Mapper
Whether this type is referenceable in a stream.- Specified by:
isReferenceable
in interfaceMapper
- Overrides:
isReferenceable
in classMapperWrapper
-
getConverterFromItemType
Description copied from interface:Mapper
Returns a single value converter to be used in a specific field.- Specified by:
getConverterFromItemType
in interfaceMapper
- Overrides:
getConverterFromItemType
in 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(Class definedIn, String attribute, Class type) Description copied from interface:Mapper
Returns which converter to use for an specific attribute in a type.- Specified by:
getConverterFromAttribute
in interfaceMapper
- Overrides:
getConverterFromAttribute
in classMapperWrapper
- Parameters:
definedIn
- the field's parentattribute
- the attribute nametype
- the type the converter should create
-
getLocalConverter
-
flushCache
public void flushCache()- Specified by:
flushCache
in interfaceCaching
-
readResolve
-
EnumMapper(Mapper)