public class CmdLineParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CmdLineParser.ValueExpected |
Modifier and Type | Field and Description |
---|---|
static char |
EndOfOpts |
Constructor and Description |
---|
CmdLineParser(java.lang.String[] args) |
Modifier and Type | Method and Description |
---|---|
char |
getNextOpt()
Get the next option.
|
java.lang.String[] |
getRemainingArgs()
Get any remaining arguments.
|
java.lang.Integer |
getValInt()
Get the value, as an Integer.
|
java.lang.String |
getValStr()
Get the value, as a string.
|
void |
registerOpt(char c,
java.lang.String s,
CmdLineParser.ValueExpected ve)
Register a command line option.
|
public static final char EndOfOpts
public CmdLineParser(java.lang.String[] args)
args
- String array of arguments passed to the program.public void registerOpt(char c, java.lang.String s, CmdLineParser.ValueExpected ve)
c
- Single character designator for this option. It cannot be '-'.s
- Full word designator for this option. This can be null, in which case
no long designator will exist for this option.ve
- If REQUIRED, a value will be expected with this option. If
OPTIONAL a value will be accepted if it is seen.java.lang.AssertionError
- if there is no short option, or if this option has already been
used.public char getNextOpt() throws java.text.ParseException
java.text.ParseException
- if an unknown option is found or an option that
expects a value does not have one or a value that does not expect a value does have
one.public java.lang.String[] getRemainingArgs()
public java.lang.String getValStr()
public java.lang.Integer getValInt() throws java.lang.NumberFormatException
java.lang.NumberFormatException
- if the value cannot be converted to an integer.Copyright © 2007-2012 The Apache Software Foundation