public abstract static class CommandLine.AbstractParseResultHandler<R> extends CommandLine.AbstractHandler<R,CommandLine.AbstractParseResultHandler<R>> implements CommandLine.IParseResultHandler2<R>
handle(CommandLine.ParseResult) with the parse result. Facilitates implementation of the CommandLine.IParseResultHandler2 interface.
Note that AbstractParseResultHandler is a generic type. This, along with the abstract self method,
allows method chaining to work properly in subclasses, without the need for casts. An example subclass can look like this:
class MyResultHandler extends AbstractParseResultHandler<MyReturnType> {
protected MyReturnType handle(ParseResult parseResult) throws ExecutionException { ... }
protected MyResultHandler self() { return this; }
}
| Constructor and Description |
|---|
AbstractParseResultHandler() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract R |
handle(CommandLine.ParseResult parseResult)
Processes the specified
ParseResult and returns the result as a list of objects. |
R |
handleParseResult(CommandLine.ParseResult parseResult)
Prints help if requested, and otherwise calls
handle(CommandLine.ParseResult). |
andExit, ansi, err, exit, exitCode, hasExitCode, out, returnResultOrExit, self, throwOrExit, useAnsi, useErr, useOutpublic R handleParseResult(CommandLine.ParseResult parseResult) throws CommandLine.ExecutionException
handle(CommandLine.ParseResult).
Finally, either a list of result objects is returned, or the JVM is terminated if an exit code was set.handleParseResult in interface CommandLine.IParseResultHandler2<R>parseResult - the ParseResult that resulted from successfully parsing the command line argumentsprocessing parse resultsCommandLine.ParameterException - if the HelpCommand was invoked for an unknown subcommand. Any ParameterExceptions
thrown from this method are treated as if this exception was thrown during parsing and passed to the CommandLine.IExceptionHandler2CommandLine.ExecutionException - if a problem occurred while processing the parse results; client code can use
CommandLine.ExecutionException.getCommandLine() to get the command or subcommand where processing failedprotected abstract R handle(CommandLine.ParseResult parseResult) throws CommandLine.ExecutionException
ParseResult and returns the result as a list of objects.
Implementations are responsible for catching any exceptions thrown in the handle method, and
rethrowing an ExecutionException that details the problem and captures the offending CommandLine object.parseResult - the ParseResult that resulted from successfully parsing the command line argumentsCommandLine.ExecutionException - if a problem occurred while processing the parse results; client code can use
CommandLine.ExecutionException.getCommandLine() to get the command or subcommand where processing failed