info.rolandkrueger.roklib.cli
Class AbstractCommandObject
java.lang.Object
info.rolandkrueger.roklib.cli.AbstractCommandObject
- Direct Known Subclasses:
- ConsoleCommandObject
public abstract class AbstractCommandObject
- extends Object
This class serves as the basis for command objects in the Command design
pattern. Every command must be initialized with a unique command name.
- Author:
- Roland Krueger
Method Summary |
String |
getName()
Returns the name of the command object. |
abstract boolean |
run(String[] args)
Executes the command whose name is found in args[0]. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mName
protected final String mName
AbstractCommandObject
public AbstractCommandObject(String name)
getName
public String getName()
- Returns the name of the command object.
- Returns:
- the name of the command object.
run
public abstract boolean run(String[] args)
- Executes the command whose name is found in args[0]. The rest of
the args array contain the command's parameters.
- Parameters:
args
- Array containing the command name as the first element and the
command's parameters in the other array elements.
- Returns:
- true if the execution of the command was successful,
false otherwise. If the command object handles execution
errors itself, it should return true afterwards to prevent
the corresponding console from printing a default error message.
Copyright © 2007-2011. All Rights Reserved.