|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.component.base.AbstractLoggableObject
net.sf.mmm.util.cli.base.AbstractCliParser
public abstract class AbstractCliParser
This is the abstract base-implementation of the CliParser interface.
| Nested Class Summary | |
|---|---|
static class |
AbstractCliParser.CliArgumentHelpInfo
This inner class holds the help information for a single CliArgument. |
static 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. |
| Field Summary | |
|---|---|
private CliState |
cliState
|
private CliParserDependencies |
dependencies
|
private static Pattern |
PATTERN_MIXED_SHORT_OPTIONS
The Pattern for a mix of multiple short-options. |
private Object |
state
|
private CliValueMap |
valueMap
The CliValueMap. |
| Fields inherited from interface net.sf.mmm.util.cli.api.CliParser |
|---|
CHAR_OPTION, END_OPTIONS, PREFIX_LONG_OPTION, PREFIX_SHORT_OPTION |
| Constructor Summary | |
|---|---|
AbstractCliParser(Object state,
CliState cliState,
CliParserDependencies dependencies)
The constructor. |
|
| Method Summary | |
|---|---|
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)
This method checks that all required
options are present if they are triggered by the
current mode. |
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)
This method handles a CliOption with an
undefined CliOption.mode(). |
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 argument,
AbstractCliParser.CliParserState parserState,
CliParameterConsumer parameterConsumer)
This method parses a single command-line argument. |
CliModeObject |
parseParameters(String... parameters)
This method parses the given command-line parameters and applies the parsed options and arguments to the
Pojo that was supplied when
building this parser. |
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. |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private 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 CliState cliState
getCliState()private final CliParserDependencies dependencies
getDependencies()private final CliValueMap valueMap
CliValueMap.
private final Object state
getState()| Constructor Detail |
|---|
public AbstractCliParser(Object state,
CliState cliState,
CliParserDependencies dependencies)
state - is the state.cliState - is the CliState.dependencies - are the dependencies with
the required components.| Method Detail |
|---|
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)
CliOption with an
undefined CliOption.mode().
option - is the CliOptionContainer.protected CliState getCliState()
CliState.
CliState.public Object getState()
CliClass
protected 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
options 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)
required
options are present if they are triggered by the
current mode.
parserState - is the current AbstractCliParser.CliParserState.
protected void parseParameter(String argument,
AbstractCliParser.CliParserState parserState,
CliParameterConsumer parameterConsumer)
argument - is the command-line argument.parserState - is the AbstractCliParser.CliParserState.parameterConsumer - is the CliParameterConsumer.public void printHelp(Appendable target)
Appendable 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)
Appendable using the given settings.
printHelp in interface CliParserappendable - is the Appendable where to print to.settings - are the CliOutputSettings used to configure the
output.protected CliParserDependencies getDependencies()
dependencies for this parser.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||