org.apache.commons.cli
public class PosixParser extends Parser
(Options,String[],boolean) flatten
method.
Version: $Revision: 542151 $
See Also: Parser
Field Summary | |
---|---|
Option | currentOption holder for the current option |
boolean | eatTheRest specifies if bursting should continue |
Options | options the command line Options |
ArrayList | tokens holder for flattened tokens |
Method Summary | |
---|---|
protected void | burstToken(String token, boolean stopAtNonOption) Breaks |
protected String[] | flatten(Options options, String[] arguments, boolean stopAtNonOption) An implementation of Parser's abstract
The following are the rules used by this flatten method. |
void | gobble(Iterator iter) Adds the remaining tokens to the processed tokens list. |
void | init() Resets the members to their original state i.e. remove
all of |
void | process(String value) If there is a current option and it can have an argument value then add the token to the processed tokens list and set the current option to null. If there is a current option and it can have argument values then add the token to the processed tokens list. If there is not a current option add the special token
"--" and the current |
void | processOptionToken(String token, boolean stopAtNonOption) |
void | processSingleHyphen(String hyphen) If it is a hyphen then add the hyphen directly to the processed tokens list. |
Breaks token
into its constituent parts
using the following algorithm.
stopAtNonOption
IS set then add the special token
"--" followed by the remaining characters and also
the remaining tokens directly to the processed tokens list.stopAtNonOption
IS NOT set then add that
character prepended with "-".Parameters: token The current token to be burst stopAtNonOption Specifies whether to stop processing at the first non-Option encountered.
An implementation of Parser's abstract
(Options,String[],boolean) flatten
method.
The following are the rules used by this flatten method.
stopAtNonOption
is true then do not
burst anymore of arguments
entries, just add each
successive entry without further processing. Otherwise, ignore
stopAtNonOption
.arguments
entry is "--"
just add the entry to the list of processed tokensarguments
entry is "-"
just add the entry to the list of processed tokensarguments
entry is two characters
in length and the first character is "-" then check if this
is a valid Option id. If it is a valid id, then add the
entry to the list of processed tokens and set the current Option
member. If it is not a valid id and stopAtNonOption
is true, then the remaining entries are copied to the list of
processed tokens. Otherwise, the current entry is ignored.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 see
burstToken
.arguments
entry is not handled
by any of the previous rules, then the entry is added to the list
of processed tokens.Parameters: options The command line Options arguments The command line arguments to be parsed stopAtNonOption Specifies whether to stop flattening when an non option is found.
Returns: The flattened arguments
String array.
Adds the remaining tokens to the processed tokens list.
Parameters: iter An iterator over the remaining tokens
Resets the members to their original state i.e. remove
all of tokens
entries, set eatTheRest
to false and set currentOption
to null.
If there is a current option and it can have an argument value then add the token to the processed tokens list and set the current option to null.
If there is a current option and it can have argument values then add the token to the processed tokens list.
If there is not a current option add the special token
"--" and the current value
to the processed
tokens list. The add all the remaining argument
values to the processed tokens list.
Parameters: value The current token
If an Option exists for token
then
set the current option and add the token to the processed
list.
If an Option does not exist and stopAtNonOption
is set then ignore the current token and add the remaining tokens
to the processed tokens list directly.
Parameters: token The current option token stopAtNonOption Specifies whether flattening should halt at the first non option.
If it is a hyphen then add the hyphen directly to the processed tokens list.
Parameters: hyphen The hyphen token