|
getopt-0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jrowe.getopt.DefaultOption
This is the default implementation of an Option
.
Fields inherited from interface jrowe.getopt.Option |
BOOLEAN_ARG,
COUNT_ARG,
INTEGER_ARG,
LIST_ARG,
NESTED_ARG,
NO_ARG,
NUMERIC_ARG,
REAL_ARG,
SCALAR_ARG,
STRING_ARG |
Constructor Summary | |
DefaultOption()
Creates a new DefaultOption with the default attributes. |
Method Summary | |
void |
clear()
Reinitializes this Option to it's default state. |
Object |
clone()
Creates and returns a copy of this object. |
Option |
createNewInstance()
Creates an Option of the same class as this
Option . |
Object |
getArg()
Returns the argument for this program option. |
int |
getArgType()
Returns the argument type for this program option. |
char |
getChar()
Returns the short name of this program option. |
Character |
getCharacter()
Returns the short name of this program option. |
int |
getMaxInstances()
Returns the maximum instances of this option that must appear if any appear at all. |
int |
getMinInstances()
Returns the minimum instances of this option that must appear if any appear at all. |
String |
getName()
Gets the long name of this object. |
static boolean |
hasArg(int argType)
Returns whether the given argument type has an argument or not. |
int |
incrementInstanceCount()
Increments the instance count of this Option . |
boolean |
isArgOptional()
Returns whether the argument for this Option is
optional |
void |
resetInstanceCount()
Resets the instance count of this Option . |
void |
runMethod()
Invokes the Runnable object that is to be run if this
program option is found. |
void |
runMethod(Object arg)
Deprecated. |
void |
setArg(Object newArg)
Sets the argument for this program option. |
void |
setArgOptional(boolean argOptional)
Sets whether the argument for this Option is
optional |
void |
setArgType(int argType)
Sets the argument type for this program option. |
void |
setChar(char c)
Sets the short name of this program option. |
void |
setCharacter(Character c)
Sets the short name of this program option. |
void |
setErrorMethod(Runnable errorMethod)
|
void |
setMaxInstances(int maxInstances)
Sets the maximum instances of this option that may appear. |
void |
setMethod(OptionMethod method)
Sets the Runnable object to invoke if the program
option is found. |
void |
setMinInstances(int minInstances)
Sets the minimum instances of this option that must appear if any appear at all. |
void |
setName(String name)
Sets the long name of this object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public DefaultOption()
DefaultOption
with the default attributes.Method Detail |
public void clear()
Option
to it's default state.public void setName(String name)
name
- the long namepublic String getName()
public void setArg(Object newArg)
newArg
- the argument for this program optionpublic Object getArg()
public void setArgType(int argType)
argType
- The type of argument this program option takes.NO_ARG
SCALAR_ARG
STRING_ARG
LIST_ARG
COUNT_ARG
NUMERIC_ARG
REAL_ARG
INTEGER_ARG
BOOLEAN_ARG
public int getArgType()
setArgType(int)
public static boolean hasArg(int argType)
argType
- the given arg typepublic void setArgOptional(boolean argOptional)
Option
is
optionalOption
is optionalpublic boolean isArgOptional()
Option
is
optionalOption
is
optionalpublic void setChar(char c)
c
- the short name of this program optionpublic char getChar()
public void setCharacter(Character c)
c
- the short name of this program optionpublic Character getCharacter()
public void setMethod(OptionMethod method)
Runnable
object to invoke if the program
option is found.method
- the object to invokepublic void runMethod()
Runnable
object that is to be run if this
program option is found.public void runMethod(Object arg)
Runnable
object that is to be run if this
program option is found.arg
- the argumentpublic void setErrorMethod(Runnable errorMethod)
public void resetInstanceCount()
Option
.public int incrementInstanceCount()
Option
.public void setMinInstances(int minInstances)
In other words, if this is set to N
, there must either be
0
instances of this Option
or there must be
at least 3
instances of this Option.
minInstances
- the minimum number of instances.1
, an
IllegalArgumentException
will be thrown.maxInstances
, property
an IllegalArgumentException
will be thrown.public int getMinInstances()
In other words, if this is set to N
, there must either be
0
instances of this Option
or there must be
at least 3
instances of this Option.
setMinInstances(int)
public void setMaxInstances(int maxInstances)
maxInstances
- the maximum number of instances.minInstances
property, an
IllegalArgumentException
will be thrown.public int getMaxInstances()
public Object clone()
Cloneable
,
Object.clone()
public String toString()
public Option createNewInstance()
Option
of the same class as this
Option
.
This is similar to the clone
method except none of the
data contained in the object is copied.
clone()
|
getopt-0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |