|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.metasyntactic.utilities.Argument
Argument is perhaps a confusing term to use for this class. Argument actually represents the switches (or non-switches) following a programname. In this example:
programname option1 option2 -f file1 -h --prefix=c:\,d:\,e:\-f,-h,--prefix are all Arguments AND there is an anonymous Argument which immediately follows the programname. Here's the confusing part. The Arguments can take from 0 to UNLIMITED options. In the previous example file1 is an option of the Argument -f, c:\ d:\ and e:\ are options of --prefix AND option1 option2 are options of the program name. option1 option2 would be considered a non-switch Argument (where there can only be one) and -f, -h and --prefix would be considered switch Arguments.
| Field Summary | |
static int |
UNLIMITED_OPTIONS
Constant to be used with maxOptions to allow an arbitrary number of arguments to follow |
| Constructor Summary | |
Argument(char switchSymbol,
java.lang.String switchName)
Creates a new switch argument with no minimum, maximum, defaults, or explanation. |
|
Argument(char switchSymbol,
java.lang.String switchName,
int minOptions,
int maxOptions,
java.lang.String[] defaultOptions,
java.lang.String explanation)
Creates a new switch argument. |
|
Argument(char switchSymbol,
java.lang.String switchName,
java.lang.String explanation)
|
|
Argument(int minOptions,
int maxOptions)
Creates a new non-switch argument with no minimum, maximum, defaults, or explanation. |
|
Argument(int minOptions,
int maxOptions,
java.lang.String explanation)
|
|
Argument(int minOptions,
int maxOptions,
java.lang.String[] defaultOptions,
java.lang.String explanation)
Creates a new non-switch argument |
|
| Method Summary | |
boolean |
equals(Argument other)
|
boolean |
equals(java.lang.Object obj)
Two arguments are equals if all of their traits are identical. |
java.lang.String[] |
getDefaultOptions()
The default Options for this Argument |
java.util.List |
getDefaultOptionsAsList()
|
java.lang.String |
getExplanation()
The explanation text for this Argument |
int |
getMaxOptions()
The maximum # of Options this argument can take. |
int |
getMinOptions()
The minimum # of Options this Arugment must take |
java.lang.String |
getSwitchName()
Gets this fully qualified name of this switch |
char |
getSwitchSymbol()
Gets the symbol for this Argument |
int |
hashCode()
|
boolean |
isSwitch()
Is this Argument a switch or not? |
static void |
main(java.lang.String[] args)
|
java.lang.String |
toString()
Returns a string representation of this argument properly formatted whether or not it is a switch |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int UNLIMITED_OPTIONS
| Constructor Detail |
public Argument(char switchSymbol,
java.lang.String switchName)
public Argument(char switchSymbol,
java.lang.String switchName,
java.lang.String explanation)
public Argument(int minOptions,
int maxOptions)
public Argument(int minOptions,
int maxOptions,
java.lang.String explanation)
public Argument(char switchSymbol,
java.lang.String switchName,
int minOptions,
int maxOptions,
java.lang.String[] defaultOptions,
java.lang.String explanation)
switchSymbol - The char to use for the switch. example: 'h' for -h.switchName - The fully qualified name of this switch. example: "help" for --help.minOptions - The minimum number of Options that this Argument must take. Use 0 if no Options are required.maxOptions - The maximum number of Options that this Argument can take. Use UNLIMITED_OPTIONS if the Argument can take an indeterminate amount of Options.defaultOptions - The default Options that will be returned if the user leaves out this switch. If this is null then the user has to specify this switch.explanation - The explanation used to explain what this switch does.
public Argument(int minOptions,
int maxOptions,
java.lang.String[] defaultOptions,
java.lang.String explanation)
minOptions - The minimum number of Options that this Argument must take. Use 0 if no Options are required.maxOptions - The maximum number of Options that this Argument can take. Use UNLIMITED_OPTIONS if the Argument can take an indeterminate amount of Options.defaultOptions - The default Options that will be returned if the user leaves out this switch. If this is null then the user has to specify this switch.explanation - The explanation used to explain what this switch does.| Method Detail |
public boolean isSwitch()
public char getSwitchSymbol()
public java.lang.String getSwitchName()
public int getMinOptions()
public int getMaxOptions()
public java.lang.String[] getDefaultOptions()
public java.util.List getDefaultOptionsAsList()
public java.lang.String getExplanation()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean equals(Argument other)
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||