Package weka.core

Class Option

java.lang.Object
weka.core.Option
All Implemented Interfaces:
RevisionHandler

public class Option extends Object implements RevisionHandler
Class to store information about an option.

Typical usage:

Option myOption = new Option("Uses extended mode.", "E", 0, "-E"));

Version:
$Revision: 15700 $
Author:
Eibe Frank (eibe@cs.waikato.ac.nz)
  • Constructor Details

    • Option

      public Option(String description, String name, int numArguments, String synopsis)
      Creates new option with the given parameters.
      Parameters:
      description - the option's description
      name - the option's name
      numArguments - the number of arguments
      synopsis - the option's synopsis
  • Method Details

    • listOptionsForClassHierarchy

      public static Vector<Option> listOptionsForClassHierarchy(Class<?> childClazz, Class<?> oldestAncestorClazz)
      Get a list of options for a class. Options identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation. All options from the class up to, but not including, the supplied oldest superclass are returned.
      Parameters:
      childClazz - the class to get options for
      oldestAncestorClazz - the oldest superclass (inclusive) at which to stop getting options from
      Returns:
      a list of options
    • listOptionsForClass

      public static Vector<Option> listOptionsForClass(Class<?> clazz)
      Gets a list of options for the supplied class. Only examines immediate methods in the class (does not consider superclasses). Options identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation.
      Parameters:
      clazz - the class to examine for options
      Returns:
      a list of options
    • getOptionsForHierarchy

      public static String[] getOptionsForHierarchy(Object target, Class<?> oldestAncestorClazz)
      Get the settings of the supplied object. Settings identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation. All options from the class up to, but not including, the supplied oldest superclass are returned.
      Parameters:
      target - the target object to get settings for
      oldestAncestorClazz - the oldest superclass at which to stop getting options from
      Returns:
    • getOptions

      public static String[] getOptions(Object target, Class<?> targetClazz)
      Get the settings of the supplied object. Settings identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation. Options belonging to the targetClazz (either the class of the target or one of its superclasses) are returned.
      Parameters:
      target - the target to extract settings from
      targetClazz - the class to consider for obtaining settings - i.e. annotated methods from this class will have their values extracted. This class is expected to be either the class of the target or one of its superclasses
      Returns:
      an array of settings
    • setOptionsForHierarchy

      public static void setOptionsForHierarchy(String[] options, Object target, Class<?> oldestAncestorClazz)
      Sets options on the target object. Settings identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation. All options from the class up to, but not including, the supplied oldest superclass are processed in order.
      Parameters:
      options - the options to set
      target - the target on which to set options
      oldestAncestorClazz - the oldest superclass at which to stop setting options
    • setOptions

      public static void setOptions(String[] options, Object target, Class<?> targetClazz)
      Sets options on the target object. Settings identified by this method are bean properties (with get/set methods) annotated using the OptionMetadata annotation. Options from just the supplied targetClazz (which is expected to be either the class of the target or one of its superclasses) are set.
      Parameters:
      options - the options to set
      target - the target on which to set options
      targetClazz - the class containing options to be be set - i.e. annotated option methods in this class will have their values set. This class is expected to be either the class of the target or one of its superclasses
    • deleteOption

      public static void deleteOption(List<Option> list, String name)
      Removes an option from a given list of options.
      Parameters:
      list - the list to reduce
      name - the name of the option
    • deleteOptionString

      public static void deleteOptionString(List<String> list, String name)
      Removes an option from a given list of strings that specifies options. This method is for an option that has a parameter value.
      Parameters:
      list - the list to reduce
      name - the name of the option (including hyphen)
    • deleteFlagString

      public static void deleteFlagString(List<String> list, String name)
      Removes an option from a given list of strings that specifies options. This method is for an option without a parameter value (i.e., a flag).
      Parameters:
      list - the list to reduce
      name - the name of the option (including hyphen)
    • description

      public String description()
      Returns the option's description.
      Returns:
      the option's description
    • name

      public String name()
      Returns the option's name.
      Returns:
      the option's name
    • numArguments

      public int numArguments()
      Returns the option's number of arguments.
      Returns:
      the option's number of arguments
    • synopsis

      public String synopsis()
      Returns the option's synopsis.
      Returns:
      the option's synopsis
    • getRevision

      public String getRevision()
      Returns the revision string.
      Specified by:
      getRevision in interface RevisionHandler
      Returns:
      the revision