org.apache.commons.cli
Class Parser
java.lang.Object
org.apache.commons.cli.Parser
- CommandLineParser
public abstract class Parser
extends java.lang.Object
- John Keyes (john at integralsource.com)
private 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
arguments that have been passed to the parse
method.
|
CommandLine | parse(Options options, String[] arguments) - Parses the specified
arguments
based on the specifed Options .
|
CommandLine | parse(Options options, String[] arguments, Properties properties) - Parse the arguments according to the specified options and
properties.
|
CommandLine | parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption) - Parse the arguments according to the specified options and
properties.
|
CommandLine | parse(Options options, String[] arguments, boolean stopAtNonOption) - Parses the specified
arguments
based on the specifed Options .
|
void | processArgs(Option opt, ListIterator iter) - Process the argument values for the specified Option
opt using the values retrieved from the
specified iterator iter .
|
private void | processOption(String arg, ListIterator iter) - Process the Option specified by
arg
using the values retrieved from the specfied iterator
iter .
|
private void | processProperties(Properties properties) - Sets the values of Options using the values in
properties .
|
options
private Options options
current Options
requiredOptions
private List requiredOptions
list of required options strings
flatten
protected abstract String[] flatten(Options opts,
String[] arguments,
boolean stopAtNonOption)
Subclasses must implement this method to reduce
the arguments
that have been passed to the parse
method.
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
- a String array of the flattened arguments
parse
public CommandLine parse(Options options,
String[] arguments,
Properties properties)
throws ParseException
Parse the arguments according to the specified options and
properties.
options
- the specified Optionsarguments
- the command line argumentsproperties
- command line option name-value pairs
- the list of atomic option and value tokens
ParseException
- if there are any problems encountered
while parsing the command line tokens.
parse
public CommandLine parse(Options options,
String[] arguments,
Properties properties,
boolean stopAtNonOption)
throws ParseException
Parse the arguments according to the specified options and
properties.
options
- the specified Optionsarguments
- the command line argumentsproperties
- command line option name-value pairsstopAtNonOption
- stop parsing the arguments when the first
non option is encountered.
- the list of atomic option and value tokens
ParseException
- if there are any problems encountered
while parsing the command line tokens.
parse
public CommandLine parse(Options options,
String[] arguments,
boolean stopAtNonOption)
throws ParseException
Parses the specified
arguments
based on the specifed
Options
.
- parse in interface CommandLineParser
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.
processArgs
public void processArgs(Option opt,
ListIterator iter)
throws ParseException
Process the argument values for the specified Option
opt
using the values retrieved from the
specified iterator iter
.
opt
- The current Optioniter
- The iterator over the flattened command line
Options.
ParseException
- if an argument value is required
and it is has not been found.
processOption
private void processOption(String arg,
ListIterator iter)
throws ParseException
Process the Option specified by arg
using the values retrieved from the specfied iterator
iter
.
arg
- The String value representing an Optioniter
- The iterator over the flattened command
line arguments.
processProperties
private void processProperties(Properties properties)
Sets the values of Options using the values in
properties
.
properties
- The value properties to be processed.