Package weka.core
Class EnumHelper
- java.lang.Object
-
- weka.core.EnumHelper
-
public class EnumHelper extends Object
Helper/wrapper class for obtaining an arbitrary enum value from an arbitrary enum type. An enum value wrapped in this class can be serialized by Weka's XML serialization mechanism.- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
-
Constructor Summary
Constructors Constructor Description EnumHelper()No-op constructor (for beans conformity)EnumHelper(Enum e)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetEnumClass()Get the fully qualified enum class nameStringgetSelectedEnumValue()Get the selected/wrapped enum value (as obtained by calling toString() on the enum value)static voidmain(String[] args)Main method for testing this classvoidsetEnumClass(String enumClass)Set the fully qualified enum class namevoidsetSelectedEnumValue(String selectedEnumValue)Set the selected/wrapped enum value (as obtained by calling toString() on the enum value)static ObjectvalueFromString(Class<?> enumClass, String enumValue)Helper method to recover an enum value given the fully qualified name of the enum and the value in question as stringsstatic ObjectvalueFromString(String enumClass, String enumValue)Helper method to recover an enum value given the fully qualified name of the enum and the value in question as strings
-
-
-
Constructor Detail
-
EnumHelper
public EnumHelper(Enum e)
Constructor- Parameters:
e- the enum value to wrap
-
EnumHelper
public EnumHelper()
No-op constructor (for beans conformity)
-
-
Method Detail
-
setEnumClass
public void setEnumClass(String enumClass)
Set the fully qualified enum class name- Parameters:
enumClass- the fully qualified name of the enum class
-
getEnumClass
public String getEnumClass()
Get the fully qualified enum class name- Returns:
- the fully qualified name of the enum class
-
setSelectedEnumValue
public void setSelectedEnumValue(String selectedEnumValue)
Set the selected/wrapped enum value (as obtained by calling toString() on the enum value)- Parameters:
selectedEnumValue- the enum value to wrap
-
getSelectedEnumValue
public String getSelectedEnumValue()
Get the selected/wrapped enum value (as obtained by calling toString() on the enum value)- Returns:
- the enum value to wrap
-
valueFromString
public static Object valueFromString(String enumClass, String enumValue) throws Exception
Helper method to recover an enum value given the fully qualified name of the enum and the value in question as strings- Parameters:
enumClass- a string containing the fully qualified name of the enum classenumValue- a string containing the value of the enum to find- Returns:
- the enum value as an Object
- Throws:
Exception- if a problem occurs
-
valueFromString
public static Object valueFromString(Class<?> enumClass, String enumValue) throws Exception
Helper method to recover an enum value given the fully qualified name of the enum and the value in question as strings- Parameters:
enumClass- the class of the enumenumValue- a string containing the value of the enum to find- Returns:
- the enum value as an Object
- Throws:
Exception- if a problem occurs
-
main
public static void main(String[] args)
Main method for testing this class- Parameters:
args- arguments
-
-