jimmc.util
Class Option
java.lang.Object
|
+--jimmc.util.Option
- public abstract class Option
- extends java.lang.Object
A command-line option.
- See Also:
OptionParser
Field Summary |
protected int |
argCount
The number of arguments used by this option. |
protected java.lang.String |
name
The name of the option, including the dash if used. |
Constructor Summary |
Option(java.lang.String name)
Create an option which takes no arguments. |
Option(java.lang.String name,
int argumentCount)
Create an option with a specified number of required arguments. |
Method Summary |
abstract void |
action(java.lang.String[] args)
The action taken when an option is specified. |
int |
getArgumentCount()
Get the number of arguments required for this option. |
java.lang.String |
getName()
Get the name of this option. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
name
protected java.lang.String name
- The name of the option, including the dash if used.
argCount
protected int argCount
- The number of arguments used by this option.
Option
public Option(java.lang.String name)
- Create an option which takes no arguments.
Option
public Option(java.lang.String name,
int argumentCount)
- Create an option with a specified number of required arguments.
action
public abstract void action(java.lang.String[] args)
- The action taken when an option is specified.
This method is called as soon as the option and its arguments
have been parsed.
- Parameters:
args
- The arguments specified for this option.
The length of this array will match the argumentCount
specified to the constructor.
If this option does not take any
arguments, args may be null.
getName
public java.lang.String getName()
- Get the name of this option.
getArgumentCount
public int getArgumentCount()
- Get the number of arguments required for this option.