|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.util.Options
Parses unix-style command-line switches. Doesn't do validation on the switches - just grabs them, and their arguments if any, and stuffs them into a HashMap.
Constructor Summary | |
Options()
|
Method Summary | |
static java.util.HashMap |
getopts(java.lang.String[] argv,
java.lang.String opts)
Parses the desired switches from an argument array. |
static java.util.HashMap |
getopts(java.lang.String args,
java.lang.String opts)
Parses the desired switches from an argument string. |
static void |
main(java.lang.String[] argv)
Tests it out. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Options()
Method Detail |
public static java.util.HashMap getopts(java.lang.String args, java.lang.String opts)
args
- the argument array as a whitespace-delimited string,
such as "-r 400 -bf -1". This method simply splits the args
string into a string array and calls getopts(String[], String).opts
- a unix-style options string, such as "oif:" or
"ab:c::d?". Each character is an switch we want to look for.
If the character is followed by a colon, it requires an argument.
If it's followed by a double-colon, it takes an optional argument.
Any non-option arguments are placed in a String array under the key "@ARGV" in the HashMap. If no non-option args are present, the "@ARGV" key will not be present in the result set.
For instance, if you passed in the option string "ab:c::d", and the argument string "-a -b foo -cd rmdir /foo/bar", the HashMap would contain:
public static java.util.HashMap getopts(java.lang.String[] argv, java.lang.String opts)
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |