public abstract class AbstractCommand extends Object implements Command
Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_OPTION_DELIMETER |
protected CommandContext |
context |
Constructor and Description |
---|
AbstractCommand() |
Modifier and Type | Method and Description |
---|---|
void |
execute(List<String> tokens)
Execute a generic command, which includes parsing the options for the
command and running the specific task.
|
protected void |
handleException(Exception exception,
String serviceUrl) |
protected void |
handleOption(String token,
List<String> tokens)
Handle the general options for each command, which includes -h, -?,
--help, -D, --version.
|
protected void |
parseOptions(List<String> tokens)
Parse any option parameters in the command arguments specified by a '-'
as the first character of the token.
|
protected abstract void |
printHelp()
Print the help messages for the specific task
|
protected void |
printHelpFromFile() |
protected abstract void |
runTask(List<String> tokens)
Run the specific task.
|
void |
setCommandContext(CommandContext context) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getOneLineDescription
public static final String COMMAND_OPTION_DELIMETER
protected CommandContext context
public AbstractCommand()
public void setCommandContext(CommandContext context)
setCommandContext
in interface Command
public void execute(List<String> tokens) throws Exception
protected void parseOptions(List<String> tokens) throws Exception
tokens
- - command argumentsException
protected void handleOption(String token, List<String> tokens) throws Exception
token
- - option token to handletokens
- - succeeding command argumentsException
protected abstract void runTask(List<String> tokens) throws Exception
tokens
- - command argumentsException
protected abstract void printHelp()
protected void printHelpFromFile()
protected void handleException(Exception exception, String serviceUrl) throws Exception
Exception
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.