Package org.apache.commons.cli
Class PosixParser
java.lang.Object
org.apache.commons.cli.Parser
org.apache.commons.cli.PosixParser
- All Implemented Interfaces:
CommandLineParser
Deprecated.
The class PosixParser provides an implementation of the
flatten
method.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
burstToken
(String token, boolean stopAtNonOption) Deprecated.Breakstoken
into its constituent parts using the following algorithm.protected String[]
private void
Deprecated.Adds the remaining tokens to the processed tokens list.private void
init()
Deprecated.Resets the members to their original state i.e.private void
processNonOptionToken
(String value, boolean stopAtNonOption) Deprecated.Add the special token "--" and the currentvalue
to the processed tokens list.private void
processOptionToken
(String token, boolean stopAtNonOption) Deprecated.If anOption
exists fortoken
then add the token to the processed list.Methods inherited from class org.apache.commons.cli.Parser
checkRequiredOptions, getOptions, getRequiredOptions, parse, parse, parse, parse, processArgs, processOption, processProperties, setOptions
-
Field Details
-
tokens
Deprecated.holder for flattened tokens -
eatTheRest
private boolean eatTheRestDeprecated.specifies if bursting should continue -
currentOption
Deprecated.holder for the current option -
options
Deprecated.The command line Options
-
-
Constructor Details
-
PosixParser
public PosixParser()Deprecated.
-
-
Method Details
-
burstToken
Deprecated.Breakstoken
into its constituent parts using the following algorithm.- ignore the first character ("-")
- for each remaining character check if an
Option
exists with that id. - if an
Option
does exist then add that character prepended with "-" to the list of processed tokens. - if the
Option
can have an argument value and there are remaining characters in the token then add the remaining characters as a token to the list of processed tokens. - if an
Option
does NOT exist ANDstopAtNonOption
IS set then add the special token "--" followed by the remaining characters and also the remaining tokens directly to the processed tokens list. - if an
Option
does NOT exist ANDstopAtNonOption
IS NOT set then add that character prepended with "-".
- Parameters:
token
- The current token to be burststopAtNonOption
- Specifies whether to stop processing at the first non-Option encountered.
-
flatten
protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException Deprecated.An implementation of
Parser
's abstractflatten
method.The following are the rules used by this flatten method.
- if
stopAtNonOption
is true then do not burst anymore ofarguments
entries, just add each successive entry without further processing. Otherwise, ignorestopAtNonOption
. - if the current
arguments
entry is "--" just add the entry to the list of processed tokens - if the current
arguments
entry is "-" just add the entry to the list of processed tokens - if the current
arguments
entry is two characters in length and the first character is "-" then check if this is a validOption
id. If it is a valid id, then add the entry to the list of processed tokens and set the currentOption
member. If it is not a valid id andstopAtNonOption
is true, then the remaining entries are copied to the list of processed tokens. Otherwise, the current entry is ignored. - if the current
arguments
entry is more than two characters in length and the first character is "-" then we need to burst the entry to determine its constituents. For more information on the bursting algorithm seeburstToken
. - if the current
arguments
entry is not handled by any of the previous rules, then the entry is added to the list of processed tokens.
- Specified by:
flatten
in classParser
- Parameters:
options
- The command lineOptions
arguments
- The command line arguments to be parsedstopAtNonOption
- Specifies whether to stop flattening when an non option is found.- Returns:
- The flattened
arguments
String array. - Throws:
ParseException
- if there are any problems encountered while parsing the command line tokens.
- if
-
gobble
Deprecated.Adds the remaining tokens to the processed tokens list.- Parameters:
iter
- An iterator over the remaining tokens
-
init
private void init()Deprecated.Resets the members to their original state i.e. remove all oftokens
entries and seteatTheRest
to false. -
processNonOptionToken
Deprecated.Add the special token "--" and the currentvalue
to the processed tokens list. Then add all the remainingargument
values to the processed tokens list.- Parameters:
value
- The current token
-
processOptionToken
Deprecated.If an
Option
exists fortoken
then add the token to the processed list.If an
Option
does not exist andstopAtNonOption
is set then add the remaining tokens to the processed tokens list directly.- Parameters:
token
- The current option tokenstopAtNonOption
- Specifies whether flattening should halt at the first non option.
-
DefaultParser
instead