public class CmdLineParser extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CmdLineParser.ValueExpected |
Modifier and Type | Field and Description |
---|---|
static char |
EndOfOpts |
Constructor and Description |
---|
CmdLineParser(String[] args) |
Modifier and Type | Method and Description |
---|---|
char |
getNextOpt()
Get the next option.
|
String[] |
getRemainingArgs()
Get any remaining arguments.
|
Integer |
getValInt()
Get the value, as an Integer.
|
String |
getValStr()
Get the value, as a string.
|
void |
registerOpt(char c,
String s,
CmdLineParser.ValueExpected ve)
Register a command line option.
|
public static final char EndOfOpts
public CmdLineParser(String[] args)
args
- String array of arguments passed to the program.public void registerOpt(char c, 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.AssertionError
- if there is no short option, or if this option has already been
used.public char getNextOpt() throws ParseException
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 String[] getRemainingArgs()
public String getValStr()
public Integer getValInt() throws NumberFormatException
NumberFormatException
- if the value cannot be converted to an integer.Copyright © 2007-2017 The Apache Software Foundation