|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jimm.twice.util.Getopts
Getopts is similar to the UN*X getopt() system call. It parses an array of Strings (usually the command line), looking for specified option flags and values. An instance of Getopts parses the whole args list at once, and stores the option flags and values that it finds.
Constructor Summary | |
Getopts(java.lang.String optionListString,
java.lang.String[] args)
This constructor takes a list of legal options and a list of (usually command line) arguments. |
Method Summary | |
int |
argc()
Return the number of non-option args. |
java.lang.String[] |
args()
Return the remaining command-line arguments. |
java.lang.String |
argv(int index)
Return a command line argument. |
boolean |
error()
Return true if there was an error while parsing the command line. |
boolean |
hasOption(char c)
Returns existence of an option. |
java.lang.String |
option(char c)
Return an option or, if missing, the empty string. |
java.lang.String |
option(char c,
java.lang.String defaultValue)
Return an option or, if missing, a default value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Getopts(java.lang.String optionListString, java.lang.String[] args)
optionListString
- option chars with optional ':' specifying arg.
For example, "ab:c" specifies three options, a, b, and c. Option b takes
a (required) argument.args
- array of command line argumentsMethod Detail |
public boolean error()
public boolean hasOption(char c)
c
- any character
public java.lang.String option(char c)
c
- the option whose value is returned
public java.lang.String option(char c, java.lang.String defaultValue)
c
- the option whose value is returneddefaultValue
- the value to return if there is no such option
public java.lang.String[] args()
argc()
,
argv(int)
public int argc()
public java.lang.String argv(int index)
index
- which argument to return
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |