org.apache.commons.cli
public abstract class Parser extends Object implements CommandLineParser
Field Summary | |
---|---|
CommandLine | cmd commandline instance |
Options | options current Options |
List | requiredOptions list of required options strings |
Method Summary | |
---|---|
void | checkRequiredOptions() Throws a MissingOptionException if all of the required options are no present. |
protected abstract String[] | flatten(Options opts, String[] arguments, boolean stopAtNonOption) Subclasses must implement this method to reduce
the |
CommandLine | parse(Options options, String[] arguments) Parses the specified |
CommandLine | parse(Options options, String[] arguments, Properties properties)
Parse the arguments according to the specified options and
properties.
|
CommandLine | parse(Options options, String[] arguments, boolean stopAtNonOption) Parses the specified |
CommandLine | parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
Parse the arguments according to the specified options and
properties.
|
void | processArgs(Option opt, ListIterator iter) Process the argument values for the specified Option
|
void | processOption(String arg, ListIterator iter) Process the Option specified by |
void | processProperties(Properties properties) Sets the values of Options using the values in
|
Throws a MissingOptionException if all of the required options are no present.
Throws: MissingOptionException if any of the required Options are not present.
Subclasses must implement this method to reduce
the arguments
that have been passed to the parse
method.
Parameters: opts The Options to parse the arguments by. arguments The arguments that have to be flattened. stopAtNonOption specifies whether to stop flattening when a non option has been encountered
Returns: a String array of the flattened arguments
Parses the specified arguments
based on the specifed Options.
Parameters: options the Options
arguments the arguments
Returns: the CommandLine
Throws: ParseException if an error occurs when parsing the arguments.
Parameters: options the specified Options arguments the command line arguments properties command line option name-value pairs
Returns: the list of atomic option and value tokens
Throws: ParseException if there are any problems encountered while parsing the command line tokens.
Parses the specified arguments
based on the specifed Options.
Parameters: options the Options
arguments the arguments
stopAtNonOption specifies whether to stop
interpreting the arguments when a non option has
been encountered and to add them to the CommandLines
args list.
Returns: the CommandLine
Throws: ParseException if an error occurs when parsing the arguments.
Parameters: options the specified Options arguments the command line arguments properties command line option name-value pairs stopAtNonOption stop parsing the arguments when the first non option is encountered.
Returns: the list of atomic option and value tokens
Throws: ParseException if there are any problems encountered while parsing the command line tokens.
Process the argument values for the specified Option
opt
using the values retrieved from the
specified iterator iter
.
Parameters: opt The current Option iter The iterator over the flattened command line Options.
Throws: ParseException if an argument value is required and it is has not been found.
Process the Option specified by arg
using the values retrieved from the specfied iterator
iter
.
Parameters: arg The String value representing an Option iter The iterator over the flattened command line arguments.
Throws: ParseException if arg
does not
represent an Option
Sets the values of Options using the values in
properties
.
Parameters: properties The value properties to be processed.