net.sf.jsefa.common.converter
Class EnumConverter

java.lang.Object
  extended by net.sf.jsefa.common.converter.EnumConverter
All Implemented Interfaces:
SimpleTypeConverter

public final class EnumConverter
extends Object
implements SimpleTypeConverter

Converter for JDK 1.5 enums.
The format is an array of mappings from the original String representation of an enum value to the one which shall be used for serialization. Each mapping has the form
originalRepresentation=newRepresentation
Example: {"SENIOR_DEVELOPER=senior developer", "JUNIOR_DEVELOPER=junior developer"}

These mappings override the display name declarations provided by the EnumConstant annotations.

It is thread safe.

Author:
Norman Lahme-Huetig

Method Summary
static EnumConverter create(SimpleTypeConverterConfiguration configuration)
          Constructs a new EnumConverter.
 Enum fromString(String value)
          Converts the given String object into an object with the simple data type this converter is intended for.
 String toString(Object value)
          Converts the given value to a String object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static EnumConverter create(SimpleTypeConverterConfiguration configuration)
Constructs a new EnumConverter.

Parameters:
configuration - the configuration
Returns:
a enum converter

fromString

public Enum fromString(String value)
Converts the given String object into an object with the simple data type this converter is intended for.

Specified by:
fromString in interface SimpleTypeConverter
Parameters:
value - the String object to convert
Returns:
the converted value

toString

public String toString(Object value)
Converts the given value to a String object.

Specified by:
toString in interface SimpleTypeConverter
Parameters:
value - the value to convert
Returns:
the converted value


Copyright © 2014. All rights reserved.