|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.common.commandline.CommandLineParser
public class CommandLineParser
The command line parser parses a command line as supplied to the main method of a class via the argument array of the main method.
| Constructor Summary | |
|---|---|
CommandLineParser()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
addArgumentOption(java.lang.String name,
java.lang.String usageMsg)
Adds an option with an argument to the list of possible options. |
void |
addArgumentOption(java.lang.String name,
java.lang.String usageMsg,
java.lang.String dflt)
Adds an option with an argument to the list of possible options. |
void |
addBooleanOption(java.lang.String name,
java.lang.String usageMsg)
Adds a boolean option to the list of possible options. |
void |
addBooleanOption(java.lang.String name,
java.lang.String usageMsg,
boolean dflt)
Adds a boolean option to the list of possible options. |
void |
addRepeatableOption(java.lang.String name,
java.lang.String usageMsg)
Adds a repeatable option with an argument (i\. e\. an option that occur more than one time) to the list of possible options. |
java.lang.String[] |
getArguments()
Retrieves the list of command arguments (i\. e\. command line arguments that don't begin with '-' or '+'. |
boolean |
getBooleanOption(java.lang.String name)
Retrieves a boolean option value. |
boolean |
getBooleanOption(java.lang.String name,
boolean dflt)
Retrieves a boolean option value with default value support. |
java.util.Iterator |
getOptions()
Retrieves an iterator of options specified on the command line. |
java.lang.String[] |
getRepeatableOption(java.lang.String name)
Retrieves a repeatable string option value. |
java.lang.String |
getStringOption(java.lang.String name)
Retrieves a string option value. |
void |
parse(java.lang.String[] args)
Parses the command line of a Java program. |
void |
printUsage()
Prints a usage message with all options to the standard error output. |
void |
printUsageAndExit()
Prints a usage message with all options to the standard error output and exits the program with error code 1. |
void |
setAcceptUnknownOptions(boolean acceptUnknownOptions)
Sets the flag if unknown options should be accepted (false by default). |
void |
setUsageMsgHeader(java.lang.String[] usageMsgHeader)
Sets the header lines for the usage message. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CommandLineParser()
| Method Detail |
|---|
public void addBooleanOption(java.lang.String name,
java.lang.String usageMsg)
name - Name of the optionusageMsg - Help message for this option
public void addBooleanOption(java.lang.String name,
java.lang.String usageMsg,
boolean dflt)
name - Name of the optionusageMsg - Help message for this optiondflt - Default value of the option
public void addArgumentOption(java.lang.String name,
java.lang.String usageMsg)
name - Name of the optionusageMsg - Help message for this option
public void addArgumentOption(java.lang.String name,
java.lang.String usageMsg,
java.lang.String dflt)
name - Name of the optionusageMsg - Help message for this optiondflt - Default value of the option
public void addRepeatableOption(java.lang.String name,
java.lang.String usageMsg)
name - Name of the optionusageMsg - Help message for this optionpublic void setAcceptUnknownOptions(boolean acceptUnknownOptions)
public void setUsageMsgHeader(java.lang.String[] usageMsgHeader)
public void parse(java.lang.String[] args)
throws CommandLineParserException
args - Array of program arguments as passed to the main method of the program
CommandLineParserException - If a supplied option is not contained in the
list of possible arguments or an option argument is missing.public void printUsageAndExit()
public void printUsage()
public java.util.Iterator getOptions()
public java.lang.String getStringOption(java.lang.String name)
throws CommandLineParserException
name - Name of the option
CommandLineParserException - On option type error
public java.lang.String[] getRepeatableOption(java.lang.String name)
throws CommandLineParserException
name - Name of the option
CommandLineParserException - On option type error
public boolean getBooleanOption(java.lang.String name,
boolean dflt)
throws CommandLineParserException
name - Name of the optiondflt - Default value of the option
CommandLineParserException - On option type error
public boolean getBooleanOption(java.lang.String name)
throws CommandLineParserException
name - Name of the option
CommandLineParserException - On option type errorpublic java.lang.String[] getArguments()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||