public abstract class AbstractCommand extends java.lang.Object implements Command
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMMAND_OPTION_DELIMETER |
protected CommandContext |
context |
Constructor and Description |
---|
AbstractCommand() |
Modifier and Type | Method and Description |
---|---|
void |
execute(java.util.List<java.lang.String> tokens)
Execute a generic command, which includes parsing the options for the
command and running the specific task.
|
protected void |
handleOption(java.lang.String token,
java.util.List<java.lang.String> tokens)
Handle the general options for each command, which includes -h, -?,
--help, -D, --version.
|
protected void |
parseOptions(java.util.List<java.lang.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 abstract void |
runTask(java.util.List<java.lang.String> tokens)
Run the specific task.
|
void |
setCommandContext(CommandContext context) |
public static final java.lang.String COMMAND_OPTION_DELIMETER
protected CommandContext context
public AbstractCommand()
public void setCommandContext(CommandContext context)
setCommandContext
in interface Command
public void execute(java.util.List<java.lang.String> tokens) throws java.lang.Exception
protected void parseOptions(java.util.List<java.lang.String> tokens) throws java.lang.Exception
tokens
- - command argumentsjava.lang.Exception
protected void handleOption(java.lang.String token, java.util.List<java.lang.String> tokens) throws java.lang.Exception
token
- - option token to handletokens
- - succeeding command argumentsjava.lang.Exception
protected abstract void runTask(java.util.List<java.lang.String> tokens) throws java.lang.Exception
tokens
- - command argumentsjava.lang.Exception
protected abstract void printHelp()
Copyright © 2005-2012. All Rights Reserved.