public class Option extends java.lang.Object implements RevisionHandler
Typical usage:
Option myOption = new Option("Uses extended mode.", "E", 0, "-E"));
| Constructor and Description |
|---|
Option(java.lang.String description,
java.lang.String name,
int numArguments,
java.lang.String synopsis)
Creates new option with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addMethodsToList(java.lang.Class<?> clazz,
java.util.List<java.lang.reflect.Method> methList)
Adds all methods from the supplied class to the supplied list of methods.
|
protected static java.lang.Object |
constructOptionHandlerValue(java.lang.String optionValue)
Construct an instance of an option handler from a String specifying its
class name and option values
|
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.
|
static void |
deleteOption(java.util.List<Option> list,
java.lang.String name)
Removes an option from a given list of options.
|
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.
|
java.lang.String |
description()
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.
|
protected static java.lang.String |
getOptionStringForOptionHandler(OptionHandler handler)
Construct a String containing the class name of an OptionHandler and its
option settings
|
java.lang.String |
getRevision()
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.String |
name()
Returns the option's name.
|
int |
numArguments()
Returns the option's number of arguments.
|
protected static void |
setOption(java.lang.reflect.Method setter,
java.lang.Object target,
java.lang.Object valueToSet)
Set an option value on a target object
|
static void |
setOptions(java.lang.String[] options,
java.lang.Object target,
java.lang.Class<?> targetClazz)
Sets options on the target object.
|
static void |
setOptionsForHierarchy(java.lang.String[] options,
java.lang.Object target,
java.lang.Class<?> oldestAncestorClazz)
Sets options on the target object.
|
java.lang.String |
synopsis()
Returns the option's synopsis.
|
public Option(java.lang.String description,
java.lang.String name,
int numArguments,
java.lang.String synopsis)
description - the option's descriptionname - the option's namenumArguments - the number of argumentssynopsis - the option's synopsispublic static java.util.Vector<Option> listOptionsForClassHierarchy(java.lang.Class<?> childClazz, java.lang.Class<?> oldestAncestorClazz)
childClazz - the class to get options foroldestAncestorClazz - the oldest superclass (inclusive) at which to
stop getting options fromprotected static void addMethodsToList(java.lang.Class<?> clazz,
java.util.List<java.lang.reflect.Method> methList)
clazz - the class to get methods frommethList - the list to add them topublic static java.util.Vector<Option> listOptionsForClass(java.lang.Class<?> clazz)
clazz - the class to examine for optionspublic static java.lang.String[] getOptionsForHierarchy(java.lang.Object target,
java.lang.Class<?> oldestAncestorClazz)
target - the target object to get settings foroldestAncestorClazz - the oldest superclass at which to stop getting
options frompublic static java.lang.String[] getOptions(java.lang.Object target,
java.lang.Class<?> targetClazz)
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 superclassesprotected static java.lang.String getOptionStringForOptionHandler(OptionHandler handler)
handler - the OptionHandler to construct an option string forpublic static void setOptionsForHierarchy(java.lang.String[] options,
java.lang.Object target,
java.lang.Class<?> oldestAncestorClazz)
options - the options to settarget - the target on which to set optionsoldestAncestorClazz - the oldest superclass at which to stop setting
optionspublic static void setOptions(java.lang.String[] options,
java.lang.Object target,
java.lang.Class<?> targetClazz)
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 superclassesprotected static java.lang.Object constructOptionHandlerValue(java.lang.String optionValue)
throws java.lang.Exception
optionValue - a String containing the class of the option handler
followed by its optionsjava.lang.Exception - if a problem occurspublic static void deleteOption(java.util.List<Option> list, java.lang.String name)
list - the list to reducename - the name of the optionpublic static void deleteOptionString(java.util.List<java.lang.String> list,
java.lang.String name)
list - the list to reducename - the name of the option (including hyphen)public static void deleteFlagString(java.util.List<java.lang.String> list,
java.lang.String name)
list - the list to reducename - the name of the option (including hyphen)protected static void setOption(java.lang.reflect.Method setter,
java.lang.Object target,
java.lang.Object valueToSet)
throws java.lang.reflect.InvocationTargetException,
java.lang.IllegalAccessException
setter - the Method object for the setter method of the option to settarget - the target object on which to set the optionvalueToSet - the value of the option to setjava.lang.reflect.InvocationTargetException - if a problem occursjava.lang.IllegalAccessException - if a problem occurspublic java.lang.String description()
public java.lang.String name()
public int numArguments()
public java.lang.String synopsis()
public java.lang.String getRevision()
getRevision in interface RevisionHandler