Module com.github.rvesse.airline
Class AbstractNameValueOptionParser<T>
java.lang.Object
com.github.rvesse.airline.parser.AbstractParser<T>
com.github.rvesse.airline.parser.options.AbstractOptionParser<T>
com.github.rvesse.airline.parser.options.AbstractNameValueOptionParser<T>
- All Implemented Interfaces:
OptionParser<T>
- Direct Known Subclasses:
ColonSeparatedOptionParser
,LongGetOptParser
Abstract option parser for options that are specified in
--name=value
style while the separator character (in
this example =
) can be configured as desired.
The separator must be a non-whitespace character.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char
private final char
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new parser with the default separator (=
)AbstractNameValueOptionParser
(char sep) Creates a new parser with the desired separator character -
Method Summary
Modifier and TypeMethodDescriptionparseOptions
(org.apache.commons.collections4.iterators.PeekingIterator<String> tokens, ParseState<T> state, List<OptionMetadata> allowedOptions) Parses one/more options from the token streamMethods inherited from class com.github.rvesse.airline.parser.options.AbstractOptionParser
findOption, findOption, hasShortNamePrefix, isSeparatorOrOption, noValueForOption
Methods inherited from class com.github.rvesse.airline.parser.AbstractParser
getTypeConverter
-
Field Details
-
DEFAULT_SEPARATOR
private static final char DEFAULT_SEPARATOR- See Also:
-
separator
private final char separator
-
-
Constructor Details
-
AbstractNameValueOptionParser
public AbstractNameValueOptionParser()Creates a new parser with the default separator (=
) -
AbstractNameValueOptionParser
public AbstractNameValueOptionParser(char sep) Creates a new parser with the desired separator character- Parameters:
sep
- Separator character, must be non-whitespace
-
-
Method Details
-
parseOptions
public ParseState<T> parseOptions(org.apache.commons.collections4.iterators.PeekingIterator<String> tokens, ParseState<T> state, List<OptionMetadata> allowedOptions) Description copied from interface:OptionParser
Parses one/more options from the token stream- Parameters:
tokens
- Tokensstate
- Current parser stateallowedOptions
- Allowed options at this point of the parsing- Returns:
- New parser state, may return
null
if this parser could not parse the next token as an option
-