public abstract class AbstractOptionParser<T> extends AbstractParser<T> implements OptionParser<T>
| Constructor and Description |
|---|
AbstractOptionParser() |
| Modifier and Type | Method and Description |
|---|---|
protected OptionMetadata |
findOption(ParseState<T> state,
List<OptionMetadata> options,
String name)
Tries to find an option with the given name
|
protected OptionMetadata |
findOption(ParseState<T> state,
List<OptionMetadata> options,
String name,
OptionMetadata defaultValue)
Tries to find an option with the given name
|
protected boolean |
hasShortNamePrefix(String name)
Return true if the option has a short name prefix i.e.
|
protected boolean |
isSeparatorOrOption(ParseState<T> state,
List<OptionMetadata> allowedOptions,
String argsSeparator,
boolean shortForm,
String peekedToken)
Checks whether the next value is an arguments separator or option
|
protected void |
noValueForOption(ParseState<T> state,
OptionMetadata option)
Reports that no/insufficient values were provided for an option
|
getTypeConverterclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitparseOptionsprotected final OptionMetadata findOption(ParseState<T> state, List<OptionMetadata> options, String name)
state - Current parser stateoptions - Allowed optionsname - Namenull otherwiseprotected final OptionMetadata findOption(ParseState<T> state, List<OptionMetadata> options, String name, OptionMetadata defaultValue)
state - Current parser stateoptions - Allowed optionsname - NamedefaultValue - Default value to return if nothing founddefaultValue otherwiseprotected boolean hasShortNamePrefix(String name)
- character. This does not
mean that it actually is a short option since definitions of what are considered a short option will vary by
concrete implementationname - Option nameprotected void noValueForOption(ParseState<T> state, OptionMetadata option)
state - Parser stateoption - Option whose value(s) are missingprotected boolean isSeparatorOrOption(ParseState<T> state, List<OptionMetadata> allowedOptions, String argsSeparator, boolean shortForm, String peekedToken)
This helps option parsers ensure they are not overly greedy when trying to consume options and their values when they should instead be raising an error because no value is provided for an option.
state - Parse StateallowedOptions - Allowed optionsargsSeparator - Arguments separatorshortForm - Whether to test only for short form, if true only consider the first character of
peekedTokenpeekedToken - The peeked token to check whether it is the arguments separator or an optionCopyright © 2012–2022. All rights reserved.