Package weka.core
Class EnumHelper
java.lang.Object
weka.core.EnumHelper
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
-
Method Summary
Modifier and TypeMethodDescriptionGet the fully qualified enum class nameGet the selected/wrapped enum value (as obtained by calling toString() on the enum value)static void
Main method for testing this classvoid
setEnumClass
(String enumClass) Set the fully qualified enum class namevoid
setSelectedEnumValue
(String selectedEnumValue) Set the selected/wrapped enum value (as obtained by calling toString() on the enum value)static Object
valueFromString
(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 Object
valueFromString
(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 Details
-
EnumHelper
Constructor- Parameters:
e
- the enum value to wrap
-
EnumHelper
public EnumHelper()No-op constructor (for beans conformity)
-
-
Method Details
-
setEnumClass
Set the fully qualified enum class name- Parameters:
enumClass
- the fully qualified name of the enum class
-
getEnumClass
Get the fully qualified enum class name- Returns:
- the fully qualified name of the enum class
-
setSelectedEnumValue
Set the selected/wrapped enum value (as obtained by calling toString() on the enum value)- Parameters:
selectedEnumValue
- the enum value to wrap
-
getSelectedEnumValue
Get the selected/wrapped enum value (as obtained by calling toString() on the enum value)- Returns:
- the enum value to wrap
-
valueFromString
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
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
Main method for testing this class- Parameters:
args
- arguments
-