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

  Modifier and Type
  Method
  Description
  `String`
  `getEnumClass()`
  Get the fully qualified enum class name
  `String`
  `getSelectedEnumValue()`
  Get the selected/wrapped enum value (as obtained by calling toString() on the enum value)
  `static void`
  `main(String[] args)`
  Main method for testing this class
  `void`
  `setEnumClass(String enumClass)`
  Set the fully qualified enum class name
  `void`
  `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 strings
  `static 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

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### EnumHelper

    public EnumHelper(Enum e)
    Constructor
    Parameters:
      `e` - the enum value to wrap

  - ### EnumHelper

    public EnumHelper()
    No-op constructor (for beans conformity)

- ## Method Details

  - ### 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 class
      `enumValue` - 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 enum
      `enumValue` - 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