Package org.apache.commons.cli
Class Parser
- java.lang.Object
-
- org.apache.commons.cli.Parser
-
- All Implemented Interfaces:
CommandLineParser
- Direct Known Subclasses:
BasicParser
,GnuParser
,PosixParser
@Deprecated public abstract class Parser extends java.lang.Object implements CommandLineParser
Deprecated.since 1.3, the two-pass parsing with the flatten method is not enough flexible to handle complex casesParser
createsCommandLine
s.- Version:
- $Id: Parser.java 1744812 2016-05-20 23:36:20Z ggregory $
-
-
Field Summary
Fields Modifier and Type Field Description protected CommandLine
cmd
Deprecated.commandline instanceprivate Options
options
Deprecated.current Optionsprivate java.util.List
requiredOptions
Deprecated.list of required options strings
-
Constructor Summary
Constructors Constructor Description Parser()
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
checkRequiredOptions()
Deprecated.Throws aMissingOptionException
if all of the required options are not present.protected abstract java.lang.String[]
flatten(Options opts, java.lang.String[] arguments, boolean stopAtNonOption)
Deprecated.Subclasses must implement this method to reduce thearguments
that have been passed to the parse method.protected Options
getOptions()
Deprecated.protected java.util.List
getRequiredOptions()
Deprecated.CommandLine
parse(Options options, java.lang.String[] arguments)
Deprecated.Parses the specifiedarguments
based on the specifiedOptions
.CommandLine
parse(Options options, java.lang.String[] arguments, boolean stopAtNonOption)
Deprecated.Parses the specifiedarguments
based on the specifiedOptions
.CommandLine
parse(Options options, java.lang.String[] arguments, java.util.Properties properties)
Deprecated.Parse the arguments according to the specified options and properties.CommandLine
parse(Options options, java.lang.String[] arguments, java.util.Properties properties, boolean stopAtNonOption)
Deprecated.Parse the arguments according to the specified options and properties.void
processArgs(Option opt, java.util.ListIterator<java.lang.String> iter)
Deprecated.Process the argument values for the specified Optionopt
using the values retrieved from the specified iteratoriter
.protected void
processOption(java.lang.String arg, java.util.ListIterator<java.lang.String> iter)
Deprecated.Process the Option specified byarg
using the values retrieved from the specified iteratoriter
.protected void
processProperties(java.util.Properties properties)
Deprecated.Sets the values of Options using the values inproperties
.protected void
setOptions(Options options)
Deprecated.private void
updateRequiredOptions(Option opt)
Deprecated.Removes the option or its group from the list of expected elements.
-
-
-
Field Detail
-
cmd
protected CommandLine cmd
Deprecated.commandline instance
-
options
private Options options
Deprecated.current Options
-
requiredOptions
private java.util.List requiredOptions
Deprecated.list of required options strings
-
-
Method Detail
-
setOptions
protected void setOptions(Options options)
Deprecated.
-
getOptions
protected Options getOptions()
Deprecated.
-
getRequiredOptions
protected java.util.List getRequiredOptions()
Deprecated.
-
flatten
protected abstract java.lang.String[] flatten(Options opts, java.lang.String[] arguments, boolean stopAtNonOption) throws ParseException
Deprecated.Subclasses must implement this method to reduce thearguments
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
- Throws:
ParseException
- if there are any problems encountered while parsing the command line tokens.
-
parse
public CommandLine parse(Options options, java.lang.String[] arguments) throws ParseException
Deprecated.Parses the specifiedarguments
based on the specifiedOptions
.- Specified by:
parse
in interfaceCommandLineParser
- Parameters:
options
- theOptions
arguments
- thearguments
- Returns:
- the
CommandLine
- Throws:
ParseException
- if there are any problems encountered while parsing the command line tokens.
-
parse
public CommandLine parse(Options options, java.lang.String[] arguments, java.util.Properties properties) throws ParseException
Deprecated.Parse the arguments according to the specified options and properties.- Parameters:
options
- the specified Optionsarguments
- the command line argumentsproperties
- 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.- Since:
- 1.1
-
parse
public CommandLine parse(Options options, java.lang.String[] arguments, boolean stopAtNonOption) throws ParseException
Deprecated.Parses the specifiedarguments
based on the specifiedOptions
.- Specified by:
parse
in interfaceCommandLineParser
- Parameters:
options
- theOptions
arguments
- thearguments
stopAtNonOption
- if true an unrecognized argument stops the parsing and the remaining arguments are added to theCommandLine
s args list. If false an unrecognized argument triggers a ParseException.- Returns:
- the
CommandLine
- Throws:
ParseException
- if an error occurs when parsing the arguments.
-
parse
public CommandLine parse(Options options, java.lang.String[] arguments, java.util.Properties properties, boolean stopAtNonOption) throws ParseException
Deprecated.Parse the arguments according to the specified options and properties.- Parameters:
options
- the specified Optionsarguments
- the command line argumentsproperties
- command line option name-value pairsstopAtNonOption
- if true an unrecognized argument stops the parsing and the remaining arguments are added to theCommandLine
s args list. If false an unrecognized argument triggers a ParseException.- Returns:
- the list of atomic option and value tokens
- Throws:
ParseException
- if there are any problems encountered while parsing the command line tokens.- Since:
- 1.1
-
processProperties
protected void processProperties(java.util.Properties properties) throws ParseException
Deprecated.Sets the values of Options using the values inproperties
.- Parameters:
properties
- The value properties to be processed.- Throws:
ParseException
- if there are any problems encountered while processing the properties.
-
checkRequiredOptions
protected void checkRequiredOptions() throws MissingOptionException
Deprecated.Throws aMissingOptionException
if all of the required options are not present.- Throws:
MissingOptionException
- if any of the required Options are not present.
-
processArgs
public void processArgs(Option opt, java.util.ListIterator<java.lang.String> iter) throws ParseException
Deprecated.Process the argument values for the specified Optionopt
using the values retrieved from the specified iteratoriter
.- Parameters:
opt
- The current Optioniter
- The iterator over the flattened command line Options.- Throws:
ParseException
- if an argument value is required and it is has not been found.
-
processOption
protected void processOption(java.lang.String arg, java.util.ListIterator<java.lang.String> iter) throws ParseException
Deprecated.Process the Option specified byarg
using the values retrieved from the specified iteratoriter
.- Parameters:
arg
- The String value representing an Optioniter
- The iterator over the flattened command line arguments.- Throws:
ParseException
- ifarg
does not represent an Option
-
updateRequiredOptions
private void updateRequiredOptions(Option opt) throws ParseException
Deprecated.Removes the option or its group from the list of expected elements.- Parameters:
opt
-- Throws:
ParseException
-
-