Package weka.core
Class Option
java.lang.Object
weka.core.Option
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteFlagString
(List<String> list, String name) Removes an option from a given list of strings that specifies options.static void
deleteOption
(List<Option> list, String name) Removes an option from a given list of options.static void
deleteOptionString
(List<String> list, String name) Removes an option from a given list of strings that specifies options.Returns the option's description.static String[]
getOptions
(Object target, Class<?> targetClazz) Get the settings of the supplied object.static String[]
getOptionsForHierarchy
(Object target, Class<?> oldestAncestorClazz) Get the settings of the supplied object.Returns the revision string.listOptionsForClass
(Class<?> clazz) Gets a list of options for the supplied class.listOptionsForClassHierarchy
(Class<?> childClazz, Class<?> oldestAncestorClazz) Get a list of options for a class.name()
Returns the option's name.int
Returns the option's number of arguments.static void
setOptions
(String[] options, Object target, Class<?> targetClazz) Sets options on the target object.static void
setOptionsForHierarchy
(String[] options, Object target, Class<?> oldestAncestorClazz) Sets options on the target object.synopsis()
Returns the option's synopsis.
-
Constructor Details
-
Option
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 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 foroldestAncestorClazz
- the oldest superclass (inclusive) at which to stop getting options from- Returns:
- a list of options
-
listOptionsForClass
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
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
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(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 settarget
- the target on which to set optionsoldestAncestorClazz
- the oldest superclass at which to stop setting options
-
setOptions
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
Removes an option from a given list of options.- Parameters:
list
- the list to reducename
- the name of the option
-
deleteOptionString
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
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
Returns the option's description.- Returns:
- the option's description
-
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
Returns the option's synopsis.- Returns:
- the option's synopsis
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-