Package weka.core
Class EnumHelper
- java.lang.Object
-
- weka.core.EnumHelper
-
public class EnumHelper extends java.lang.ObjectHelper/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(java.lang.Enum e)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetEnumClass()Get the fully qualified enum class namejava.lang.StringgetSelectedEnumValue()Get the selected/wrapped enum value (as obtained by calling toString() on the enum value)static voidmain(java.lang.String[] args)Main method for testing this classvoidsetEnumClass(java.lang.String enumClass)Set the fully qualified enum class namevoidsetSelectedEnumValue(java.lang.String selectedEnumValue)Set the selected/wrapped enum value (as obtained by calling toString() on the enum value)static java.lang.ObjectvalueFromString(java.lang.Class<?> enumClass, java.lang.String enumValue)Helper method to recover an enum value given the fully qualified name of the enum and the value in question as stringsstatic java.lang.ObjectvalueFromString(java.lang.String enumClass, java.lang.String enumValue)Helper method to recover an enum value given the fully qualified name of the enum and the value in question as strings
-
-
-
Method Detail
-
setEnumClass
public void setEnumClass(java.lang.String enumClass)
Set the fully qualified enum class name- Parameters:
enumClass- the fully qualified name of the enum class
-
getEnumClass
public java.lang.String getEnumClass()
Get the fully qualified enum class name- Returns:
- the fully qualified name of the enum class
-
setSelectedEnumValue
public void setSelectedEnumValue(java.lang.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 java.lang.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 java.lang.Object valueFromString(java.lang.String enumClass, java.lang.String enumValue) throws java.lang.ExceptionHelper 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:
java.lang.Exception- if a problem occurs
-
valueFromString
public static java.lang.Object valueFromString(java.lang.Class<?> enumClass, java.lang.String enumValue) throws java.lang.ExceptionHelper 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:
java.lang.Exception- if a problem occurs
-
main
public static void main(java.lang.String[] args)
Main method for testing this class- Parameters:
args- arguments
-
-