org.databene.commons.converter
Class String2EnumConverter<E extends java.lang.Enum>

java.lang.Object
  extended by org.databene.commons.converter.AbstractConverter<S,T>
      extended by org.databene.commons.converter.ThreadSafeConverter<java.lang.String,E>
          extended by org.databene.commons.converter.String2EnumConverter<E>
All Implemented Interfaces:
java.lang.Cloneable, Converter<java.lang.String,E>, ThreadAware

public class String2EnumConverter<E extends java.lang.Enum>
extends ThreadSafeConverter<java.lang.String,E>

Instantiates enum instances by their name.

Created: 20.08.2007 07:11:16

Author:
Volker Bergmann

Field Summary
 
Fields inherited from class org.databene.commons.converter.AbstractConverter
sourceType, targetType
 
Constructor Summary
String2EnumConverter(java.lang.Class<E> enumClass)
           
 
Method Summary
 E convert(java.lang.String sourceValue)
          Concerts an object of type S to an object of type T
static
<T extends java.lang.Enum>
T
convert(java.lang.String sourceValue, java.lang.Class<T> enumClass)
           
 
Methods inherited from class org.databene.commons.converter.ThreadSafeConverter
clone, isParallelizable, isThreadSafe
 
Methods inherited from class org.databene.commons.converter.AbstractConverter
getSourceType, getTargetType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

String2EnumConverter

public String2EnumConverter(java.lang.Class<E> enumClass)
Method Detail

convert

public E convert(java.lang.String sourceValue)
                                 throws ConversionException
Description copied from interface: Converter
Concerts an object of type S to an object of type T

Parameters:
sourceValue - the object to convert
Returns:
the converted object
Throws:
ConversionException - if the conversion fails

convert

public static <T extends java.lang.Enum> T convert(java.lang.String sourceValue,
                                                   java.lang.Class<T> enumClass)
                                        throws ConversionException
Throws:
ConversionException


Copyright © 2010. All Rights Reserved.