public abstract class AbstractCliParser extends AbstractLoggableObject implements CliParser
CliParser interface.| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractCliParser.CliArgumentHelpInfo
This inner class holds the help information for a single
CliArgument. |
class |
AbstractCliParser.CliHelpWriter
This inner class is a helper to simplify writing the help-usage.
|
protected static class |
AbstractCliParser.CliOptionHelpInfo
This inner class holds the help information for a single
CliOption. |
protected static class |
AbstractCliParser.CliParserState
This inner class holds the state of the
argument parsing. |
| Modifier and Type | Field and Description |
|---|---|
private CliState |
cliState |
private CliParserDependencies |
dependencies |
private NlsBundleUtilCliRoot |
nlsBundle |
private static Pattern |
PATTERN_MIXED_SHORT_OPTIONS
The
Pattern for a mix of multiple short-options. |
private Object |
state |
private CliValueMap |
valueMap
The
CliValueMap. |
CHAR_OPTION, END_OPTIONS, PREFIX_LONG_OPTION, PREFIX_SHORT_OPTION| Constructor and Description |
|---|
AbstractCliParser(Object state,
CliState cliState,
CliParserDependencies dependencies)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkOption(CliOptionContainer optionContainer)
This method checks a
CliOption for correctness. |
protected void |
checkOptionName(String name,
CliOptionContainer optionContainer)
This method checks the given
name of the given option. |
protected void |
checkRequiredParameters(AbstractCliParser.CliParserState parserState)
|
protected CliState |
getCliState()
This method gets the
CliState. |
protected CliParserDependencies |
getDependencies() |
Object |
getState()
This method gets the instance of the state where the command-line arguments should be applied to.
|
protected void |
handleUndefinedMode(CliOptionContainer option)
|
protected void |
parseArgument(AbstractCliParser.CliParserState parserState,
String argument,
CliArgumentContainer argumentContainer,
CliParameterConsumer parameterConsumer)
This method parses the value of a
CliOption. |
protected void |
parseOption(AbstractCliParser.CliParserState parserState,
String option,
CliOptionContainer optionContainer,
CliParameterConsumer parameterConsumer)
This method parses the value of a
CliOption. |
protected void |
parseParameter(String parameter,
AbstractCliParser.CliParserState parserState,
CliParameterConsumer parameterConsumer)
This method parses a single command-line argument.
|
CliModeObject |
parseParameters(String... parameters)
|
private void |
parseParameterUndefinedOption(String parameter,
AbstractCliParser.CliParserState parserState,
CliParameterConsumer parameterConsumer)
Parses the given commandline
parameter that is no defined CliOption. |
void |
printHelp(Appendable target)
This method prints the help (program usage) generated from the annotations to the given
Appendable using
default settings. |
void |
printHelp(Appendable appendable,
CliOutputSettings settings)
This method prints the help (program usage) generated from the annotations to the given
Appendable using
the given settings. |
private int |
printHelpOptions(CliOutputSettings settings,
Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap,
StringBuilder parameters,
Collection<CliOptionContainer> modeOptions)
Prints the options for the help usage output.
|
getLoggerprivate static final Pattern PATTERN_MIXED_SHORT_OPTIONS
Pattern for a mix of multiple short-options. E.g. "-vpa" instead of "-v", "-p" and "-a".private final NlsBundleUtilCliRoot nlsBundle
private final CliState cliState
private final CliParserDependencies dependencies
private final CliValueMap valueMap
CliValueMap.private final Object state
public AbstractCliParser(Object state, CliState cliState, CliParserDependencies dependencies)
state - is the state.cliState - is the CliState.dependencies - are the dependencies with the required components.protected void checkOption(CliOptionContainer optionContainer)
CliOption for correctness.optionContainer - is the CliOptionContainer.protected void checkOptionName(String name, CliOptionContainer optionContainer)
name of the given option.name - is the name or alias.optionContainer - is the CliOptionContainer.protected void handleUndefinedMode(CliOptionContainer option)
option - is the CliOptionContainer.public Object getState()
CliClassprotected void parseOption(AbstractCliParser.CliParserState parserState, String option, CliOptionContainer optionContainer, CliParameterConsumer parameterConsumer)
CliOption.parserState - is the AbstractCliParser.CliParserState.option - is the command-line parameter that triggered the given optionContainer.optionContainer - is the CliOptionContainer for the current option that has already been detected.parameterConsumer - is the CliParameterConsumer.protected void parseArgument(AbstractCliParser.CliParserState parserState, String argument, CliArgumentContainer argumentContainer, CliParameterConsumer parameterConsumer)
CliOption.parserState - is the AbstractCliParser.CliParserState.argument - is the commandline parameter.argumentContainer - is the CliArgumentContainer for the current argument.parameterConsumer - is the CliParameterConsumer.public CliModeObject parseParameters(String... parameters) throws CliException
CliParseroptions and
arguments to the Pojo that was supplied when
building this parser.parseParameters in interface CliParserparameters - are the command-line arguments of the main-program.mode that was triggered.CliException - if the given arguments are invalid.protected void checkRequiredParameters(AbstractCliParser.CliParserState parserState)
parserState - is the current AbstractCliParser.CliParserState.protected void parseParameter(String parameter, AbstractCliParser.CliParserState parserState, CliParameterConsumer parameterConsumer)
parameter - is the command-line argument.parserState - is the AbstractCliParser.CliParserState.parameterConsumer - is the CliParameterConsumer.private void parseParameterUndefinedOption(String parameter, AbstractCliParser.CliParserState parserState, CliParameterConsumer parameterConsumer)
parameter that is no defined CliOption.parameter - is the commandline argument.parserState - is the current AbstractCliParser.CliParserState.parameterConsumer - is the CliParameterConsumer.public void printHelp(Appendable target)
CliParserAppendable using
default settings.printHelp in interface CliParsertarget - is the Appendable where to print to.CliParser.printHelp(Appendable, CliOutputSettings)public void printHelp(Appendable appendable, CliOutputSettings settings)
CliParserAppendable using
the given settings.printHelp in interface CliParserappendable - is the Appendable where to print to.settings - are the CliOutputSettings used to configure the output.private int printHelpOptions(CliOutputSettings settings, Map<CliOption,AbstractCliParser.CliOptionHelpInfo> option2HelpMap, StringBuilder parameters, Collection<CliOptionContainer> modeOptions)
settings - are the CliOutputSettings.option2HelpMap - is the Map with the AbstractCliParser.CliOptionHelpInfo.parameters - is the StringBuilder where to append the options
help output.modeOptions - the Collection with the options to print for the current mode.protected CliParserDependencies getDependencies()
dependencies for this parser.Copyright © 2001–2016 mmm-Team. All rights reserved.