DefaultParser
instead@Deprecated public class PosixParser extends Parser
flatten
method.Modifier and Type | Field and Description |
---|---|
private Option |
currentOption
Deprecated.
holder for the current option
|
private boolean |
eatTheRest
Deprecated.
specifies if bursting should continue
|
private Options |
options
Deprecated.
the command line Options
|
private java.util.List<java.lang.String> |
tokens
Deprecated.
holder for flattened tokens
|
Constructor and Description |
---|
PosixParser()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
burstToken(java.lang.String token,
boolean stopAtNonOption)
Deprecated.
Breaks
token into its constituent parts
using the following algorithm. |
protected java.lang.String[] |
flatten(Options options,
java.lang.String[] arguments,
boolean stopAtNonOption)
Deprecated.
|
private void |
gobble(java.util.Iterator<java.lang.String> iter)
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(java.lang.String value,
boolean stopAtNonOption)
Deprecated.
Add the special token "--" and the current
value
to the processed tokens list. |
private void |
processOptionToken(java.lang.String token,
boolean stopAtNonOption)
Deprecated.
If an
Option exists for token then
add the token to the processed list. |
checkRequiredOptions, getOptions, getRequiredOptions, parse, parse, parse, parse, processArgs, processOption, processProperties, setOptions
private final java.util.List<java.lang.String> tokens
private boolean eatTheRest
private Option currentOption
private Options options
private void init()
tokens
entries and set eatTheRest
to false.protected java.lang.String[] flatten(Options options, java.lang.String[] arguments, boolean stopAtNonOption) throws ParseException
An implementation of Parser
's abstract
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.flatten
in class Parser
options
- The command line Options
arguments
- The command line arguments to be parsedstopAtNonOption
- Specifies whether to stop flattening
when an non option is found.arguments
String array.ParseException
- if there are any problems encountered
while parsing the command line tokens.private void gobble(java.util.Iterator<java.lang.String> iter)
iter
- An iterator over the remaining tokensprivate void processNonOptionToken(java.lang.String value, boolean stopAtNonOption)
value
to the processed tokens list. Then add all the remaining
argument
values to the processed tokens list.value
- The current tokenprivate void processOptionToken(java.lang.String token, boolean stopAtNonOption)
If an Option
exists for token
then
add the token to the processed list.
If an Option
does not exist and stopAtNonOption
is set then add the remaining tokens to the processed tokens list
directly.
token
- The current option tokenstopAtNonOption
- Specifies whether flattening should halt
at the first non option.protected void burstToken(java.lang.String token, boolean stopAtNonOption)
token
into its constituent parts
using the following algorithm.
Option
exists with that id.Option
does exist then add that character
prepended with "-" to the list of processed tokens.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.Option
does NOT exist AND
stopAtNonOption
IS set then add the special token
"--" followed by the remaining characters and also
the remaining tokens directly to the processed tokens list.Option
does NOT exist AND
stopAtNonOption
IS NOT set then add that
character prepended with "-".token
- The current token to be burststopAtNonOption
- Specifies whether to stop processing
at the first non-Option encountered.