|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sadun.util.CmdLineOptions.Handler
This class handles an option and can be subclassed to define the reaction to the discovery of an option.
| Nested Class Summary | |
static class |
CmdLineOptions.Handler.ParamSet
A set of parmeters for an option |
| Field Summary | |
protected java.lang.String[] |
aliases
The aliases for the option |
protected java.lang.String |
description
The description for the option |
protected java.lang.String |
option
The option literal |
protected int |
priority
The priority of the option |
| Constructor Summary | |
CmdLineOptions.Handler(java.lang.String option)
Build an handler which recognizes the given option literal (at zero priority). |
|
CmdLineOptions.Handler(java.lang.String option,
java.lang.String description)
Build an handler which recognizes the given option literal (at zero priority). |
|
CmdLineOptions.Handler(java.lang.String option,
java.lang.String description,
java.lang.String aliases)
Build an handler which recognizes the given option literal, the given aliases and the given description (at zero priority). |
|
CmdLineOptions.Handler(java.lang.String option,
java.lang.String description,
java.lang.String aliases,
int priority)
Build an handler which recognizes the given option literal, the given aliases, the given description and the given priority. |
|
| Method Summary | |
void |
addAliases(java.lang.String aliases)
Adds aliases for the option handled by this handler, in comma-separated format. |
void |
addAliases(java.lang.String[] aliases)
Adds aliases for the option handled by this handler. |
int |
compareTo(java.lang.Object obj)
|
protected java.lang.String[] |
getAliases()
Return the array of aliases for this handler. |
java.lang.String |
getDescription()
Return a description for the handled option - which is included in the usage()
string. |
int |
getPriority()
Return the priority of the handler. |
protected abstract void |
option(java.lang.String option,
CmdLineOptions.Handler.ParamSet ps,
boolean value)
This method must be overridden by an implementation to define the behaviour of the handler when an option is found. |
void |
setAliases(java.lang.String aliases)
Sets the aliases for the option handled by this handler, in comma-separated format. |
void |
setAliases(java.lang.String[] aliases)
Sets the aliases for the option handled by this handler. |
void |
setDescription(java.lang.String description)
Set a description for the handled option - which is included in the usage()
string. |
void |
setPriority(int priority)
Set the priority of the handler. |
java.lang.String |
toString()
Return a description of the handler. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.String option
protected java.lang.String description
protected java.lang.String[] aliases
protected int priority
| Constructor Detail |
public CmdLineOptions.Handler(java.lang.String option,
java.lang.String description,
java.lang.String aliases,
int priority)
priority - the priority of the option.option - the option literal.description - a description for the option.aliases - the option aliases, in comma-separated format.
public CmdLineOptions.Handler(java.lang.String option,
java.lang.String description,
java.lang.String aliases)
option - the option literal.
public CmdLineOptions.Handler(java.lang.String option,
java.lang.String description)
option - the option literal.public CmdLineOptions.Handler(java.lang.String option)
option - the option literal.| Method Detail |
public void setDescription(java.lang.String description)
usage()
string.
description - a short description of the tool.public java.lang.String getDescription()
usage()
string.
usage()
string.public java.lang.String toString()
Object.toString()protected java.lang.String[] getAliases()
public void setPriority(int priority)
CmdLineOptions.parse(String[]).
priority - the priority of the handlerpublic int getPriority()
CmdLineOptions.parse(String[])
public void addAliases(java.lang.String[] aliases)
aliases - the option aliases.public void addAliases(java.lang.String aliases)
aliases - the option aliases, in comma-separated format.public void setAliases(java.lang.String aliases)
aliases - the option aliases, in comma-separated format.public void setAliases(java.lang.String[] aliases)
aliases - the option aliases.
protected abstract void option(java.lang.String option,
CmdLineOptions.Handler.ParamSet ps,
boolean value)
It receives the option literal (stripped of the option prefix and postfix), a ParamSet object with additional non-optional parameters and the "set/unset" value of the option.
option - the option literal.ps - a ParamSet object, to browse option parameters.value - specifies if the option has been set or unset.public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.ComparableComparable.compareTo(Object)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||