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 public class PosixParser extends Parser
Deprecated.since 1.3, use theDefaultParserinsteadThe class PosixParser provides an implementation of theflattenmethod.- Version:
- $Id: PosixParser.java 1783175 2017-02-16 07:52:05Z britter $
-
-
Field Summary
Fields Modifier and Type Field Description private OptioncurrentOptionDeprecated.holder for the current optionprivate booleaneatTheRestDeprecated.specifies if bursting should continueprivate OptionsoptionsDeprecated.the command line Optionsprivate java.util.List<java.lang.String>tokensDeprecated.holder for flattened tokens
-
Constructor Summary
Constructors Constructor Description PosixParser()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidburstToken(java.lang.String token, boolean stopAtNonOption)Deprecated.Breakstokeninto its constituent parts using the following algorithm.protected java.lang.String[]flatten(Options options, java.lang.String[] arguments, boolean stopAtNonOption)Deprecated.private voidgobble(java.util.Iterator<java.lang.String> iter)Deprecated.Adds the remaining tokens to the processed tokens list.private voidinit()Deprecated.Resets the members to their original state i.e.private voidprocessNonOptionToken(java.lang.String value, boolean stopAtNonOption)Deprecated.Add the special token "--" and the currentvalueto the processed tokens list.private voidprocessOptionToken(java.lang.String token, boolean stopAtNonOption)Deprecated.If anOptionexists fortokenthen 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 Detail
-
tokens
private final java.util.List<java.lang.String> tokens
Deprecated.holder for flattened tokens
-
eatTheRest
private boolean eatTheRest
Deprecated.specifies if bursting should continue
-
currentOption
private Option currentOption
Deprecated.holder for the current option
-
options
private Options options
Deprecated.the command line Options
-
-
Method Detail
-
init
private void init()
Deprecated.Resets the members to their original state i.e. remove all oftokensentries and seteatTheRestto false.
-
flatten
protected java.lang.String[] flatten(Options options, java.lang.String[] arguments, boolean stopAtNonOption) throws ParseException
Deprecated.An implementation of
Parser's abstractflattenmethod.The following are the rules used by this flatten method.
- if
stopAtNonOptionis true then do not burst anymore ofargumentsentries, just add each successive entry without further processing. Otherwise, ignorestopAtNonOption. - if the current
argumentsentry is "--" just add the entry to the list of processed tokens - if the current
argumentsentry is "-" just add the entry to the list of processed tokens - if the current
argumentsentry is two characters in length and the first character is "-" then check if this is a validOptionid. If it is a valid id, then add the entry to the list of processed tokens and set the currentOptionmember. If it is not a valid id andstopAtNonOptionis true, then the remaining entries are copied to the list of processed tokens. Otherwise, the current entry is ignored. - if the current
argumentsentry 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
argumentsentry is not handled by any of the previous rules, then the entry is added to the list of processed tokens.
- Specified by:
flattenin classParser- Parameters:
options- The command lineOptionsarguments- The command line arguments to be parsedstopAtNonOption- Specifies whether to stop flattening when an non option is found.- Returns:
- The flattened
argumentsString array. - Throws:
ParseException- if there are any problems encountered while parsing the command line tokens.
- if
-
gobble
private void gobble(java.util.Iterator<java.lang.String> iter)
Deprecated.Adds the remaining tokens to the processed tokens list.- Parameters:
iter- An iterator over the remaining tokens
-
processNonOptionToken
private void processNonOptionToken(java.lang.String value, boolean stopAtNonOption)Deprecated.Add the special token "--" and the currentvalueto the processed tokens list. Then add all the remainingargumentvalues to the processed tokens list.- Parameters:
value- The current token
-
processOptionToken
private void processOptionToken(java.lang.String token, boolean stopAtNonOption)Deprecated.If an
Optionexists fortokenthen add the token to the processed list.If an
Optiondoes not exist andstopAtNonOptionis 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.
-
burstToken
protected void burstToken(java.lang.String token, boolean stopAtNonOption)Deprecated.Breakstokeninto its constituent parts using the following algorithm.- ignore the first character ("-")
- for each remaining character check if an
Optionexists with that id. - if an
Optiondoes exist then add that character prepended with "-" to the list of processed tokens. - if the
Optioncan 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
Optiondoes NOT exist ANDstopAtNonOptionIS set then add the special token "--" followed by the remaining characters and also the remaining tokens directly to the processed tokens list. - if an
Optiondoes NOT exist ANDstopAtNonOptionIS 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.
-
-