public class

EnumMapper

extends MapperWrapper
java.lang.Object
   ↳ com.thoughtworks.xstream.mapper.MapperWrapper
     ↳ com.thoughtworks.xstream.mapper.EnumMapper

Class Overview

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.

Summary

Public Constructors
EnumMapper(Mapper wrapped, ConverterLookup lookup)
This constructor is deprecated. since 1.3.1, use EnumMapper(Mapper)
EnumMapper(Mapper wrapped)
EnumMapper(ClassMapper wrapped)
This constructor is deprecated. since 1.2, use
Public Methods
SingleValueConverter getConverterFromAttribute(Class definedIn, String attribute, Class type)
Returns which converter to use for an specific attribute in a type.
SingleValueConverter getConverterFromItemType(String fieldName, Class type, Class definedIn)
Returns a single value converter to be used in a specific field.
boolean isImmutableValueType(Class type)
Whether this type is a simple immutable value (int, boolean, String, URL, etc.
String serializedClass(Class type)
How a class name should be represented in its serialized form.
[Expand]
Inherited Methods
From class com.thoughtworks.xstream.mapper.MapperWrapper
From class java.lang.Object
From interface com.thoughtworks.xstream.mapper.Mapper

Public Constructors

public EnumMapper (Mapper wrapped, ConverterLookup lookup)

This constructor is deprecated.
since 1.3.1, use EnumMapper(Mapper)

public EnumMapper (Mapper wrapped)

public EnumMapper (ClassMapper wrapped)

This constructor is deprecated.
since 1.2, use

Public Methods

public SingleValueConverter getConverterFromAttribute (Class definedIn, String attribute, Class type)

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

Parameters
definedIn the field's parent
attribute the attribute name
type the type the converter should create

public SingleValueConverter getConverterFromItemType (String fieldName, Class type, Class definedIn)

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

Parameters
fieldName the field name
type the field type
definedIn the type which defines this field
Returns
  • a SingleValueConverter or null if there no such converter should be used for this field.

public boolean isImmutableValueType (Class type)

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.

public String serializedClass (Class type)

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