Class EnumTransform

java.lang.Object
org.simpleframework.xml.transform.EnumTransform
All Implemented Interfaces:
Transform<Enum>

class EnumTransform extends Object implements Transform<Enum>
The EnumTransform represents a transform that is used to transform enumerations to strings and back again. This is used when enumerations are used in comma separated arrays. This may be created multiple times for different types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Class
    This is the specific enumeration that this transforms.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the EnumTransform object.
  • Method Summary

    Modifier and Type
    Method
    Description
    read(String value)
    This method is used to convert the string value given to an appropriate representation.
    write(Enum value)
    This method is used to convert the provided value into an XML usable format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • type

      private final Class type
      This is the specific enumeration that this transforms.
  • Constructor Details

    • EnumTransform

      public EnumTransform(Class type)
      Constructor for the EnumTransform object. This is used to create enumerations from strings and convert them back again. This allows enumerations to be used in arrays.
      Parameters:
      type - this is the enumeration type to be transformed
  • Method Details

    • read

      public Enum read(String value) throws Exception
      This method is used to convert the string value given to an appropriate representation. This is used when an object is being deserialized from the XML document and the value for the string representation is required.
      Specified by:
      read in interface Transform<Enum>
      Parameters:
      value - this is the string representation of the value
      Returns:
      this returns an appropriate instanced to be used
      Throws:
      Exception
    • write

      public String write(Enum value) throws Exception
      This method is used to convert the provided value into an XML usable format. This is used in the serialization process when there is a need to convert a field value in to a string so that that value can be written as a valid XML entity.
      Specified by:
      write in interface Transform<Enum>
      Parameters:
      value - this is the value to be converted to a string
      Returns:
      this is the string representation of the given value
      Throws:
      Exception