Package weka.core
Class Option
- java.lang.Object
-
- weka.core.Option
-
- All Implemented Interfaces:
RevisionHandler
public class Option extends java.lang.Object implements RevisionHandler
Class to store information about an option.Typical usage:
Option myOption = new Option("Uses extended mode.", "E", 0, "-E"));- Version:
- $Revision: 14848 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
-
-
Constructor Summary
Constructors Constructor Description Option(java.lang.String description, java.lang.String name, int numArguments, java.lang.String synopsis)Creates new option with the given parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voiddeleteFlagString(java.util.List<java.lang.String> list, java.lang.String name)Removes an option from a given list of strings that specifies options.static voiddeleteOption(java.util.List<Option> list, java.lang.String name)Removes an option from a given list of options.static voiddeleteOptionString(java.util.List<java.lang.String> list, java.lang.String name)Removes an option from a given list of strings that specifies options.java.lang.Stringdescription()Returns the option's description.static java.lang.String[]getOptions(java.lang.Object target, java.lang.Class<?> targetClazz)Get the settings of the supplied object.static java.lang.String[]getOptionsForHierarchy(java.lang.Object target, java.lang.Class<?> oldestAncestorClazz)Get the settings of the supplied object.java.lang.StringgetRevision()Returns the revision string.static java.util.Vector<Option>listOptionsForClass(java.lang.Class<?> clazz)Gets a list of options for the supplied class.static java.util.Vector<Option>listOptionsForClassHierarchy(java.lang.Class<?> childClazz, java.lang.Class<?> oldestAncestorClazz)Get a list of options for a class.java.lang.Stringname()Returns the option's name.intnumArguments()Returns the option's number of arguments.static voidsetOptions(java.lang.String[] options, java.lang.Object target, java.lang.Class<?> targetClazz)Sets options on the target object.static voidsetOptionsForHierarchy(java.lang.String[] options, java.lang.Object target, java.lang.Class<?> oldestAncestorClazz)Sets options on the target object.java.lang.Stringsynopsis()Returns the option's synopsis.
-
-
-
Constructor Detail
-
Option
public Option(java.lang.String description, java.lang.String name, int numArguments, java.lang.String synopsis)Creates new option with the given parameters.- Parameters:
description- the option's descriptionname- the option's namenumArguments- the number of argumentssynopsis- the option's synopsis
-
-
Method Detail
-
listOptionsForClassHierarchy
public static java.util.Vector<Option> listOptionsForClassHierarchy(java.lang.Class<?> childClazz, java.lang.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 foroldestAncestorClazz- the oldest superclass (inclusive) at which to stop getting options from- Returns:
- a list of options
-
listOptionsForClass
public static java.util.Vector<Option> listOptionsForClass(java.lang.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 java.lang.String[] getOptionsForHierarchy(java.lang.Object target, java.lang.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 foroldestAncestorClazz- the oldest superclass at which to stop getting options from- Returns:
-
getOptions
public static java.lang.String[] getOptions(java.lang.Object target, java.lang.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 fromtargetClazz- 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(java.lang.String[] options, java.lang.Object target, java.lang.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 settarget- the target on which to set optionsoldestAncestorClazz- the oldest superclass at which to stop setting options
-
setOptions
public static void setOptions(java.lang.String[] options, java.lang.Object target, java.lang.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 settarget- the target on which to set optionstargetClazz- 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(java.util.List<Option> list, java.lang.String name)
Removes an option from a given list of options.- Parameters:
list- the list to reducename- the name of the option
-
deleteOptionString
public static void deleteOptionString(java.util.List<java.lang.String> list, java.lang.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 reducename- the name of the option (including hyphen)
-
deleteFlagString
public static void deleteFlagString(java.util.List<java.lang.String> list, java.lang.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 reducename- the name of the option (including hyphen)
-
description
public java.lang.String description()
Returns the option's description.- Returns:
- the option's description
-
name
public java.lang.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 java.lang.String synopsis()
Returns the option's synopsis.- Returns:
- the option's synopsis
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
-