ikrs.util
Class AbstractCommand

java.lang.Object
  extended by ikrs.util.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
DefaultCommand

public abstract class AbstractCommand
extends java.lang.Object
implements Command


Constructor Summary
AbstractCommand(java.lang.String name, BasicType[] params)
           
 
Method Summary
abstract  int execute()
          This is the final execution method.
 java.lang.String getName()
          This is the basic command name, such as "ls", "wget" or "git".
 BasicType getParamAt(int index)
          Get the param at the given index.
 int getParamCount()
          Get the number of params this command has.
protected  void setName(java.lang.String name)
           
protected  void setParams(BasicType[] params)
           
 java.lang.String toString()
           
 java.lang.StringBuffer toString(java.lang.StringBuffer b)
          Convert this command into a parseable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractCommand

public AbstractCommand(java.lang.String name,
                       BasicType[] params)
Method Detail

setName

protected void setName(java.lang.String name)

setParams

protected void setParams(BasicType[] params)

getName

public java.lang.String getName()
This is the basic command name, such as "ls", "wget" or "git".

Specified by:
getName in interface Command

getParamCount

public int getParamCount()
Get the number of params this command has. The command name itself does not belong to the param list.

Specified by:
getParamCount in interface Command

getParamAt

public BasicType getParamAt(int index)
                     throws java.lang.IndexOutOfBoundsException
Get the param at the given index. The param indices range from 0 to getParamCount()-1.

Specified by:
getParamAt in interface Command
Parameters:
index - the param index.
Throws:
java.lang.IndexOutOfBoundsException

toString

public java.lang.StringBuffer toString(java.lang.StringBuffer b)
Convert this command into a parseable string. The string will be stored in the given string buffer.

Specified by:
toString in interface Command
Parameters:
b - The stringbuffer to append this command to.

execute

public abstract int execute()
This is the final execution method. Note that this method does _not_ throw any exceptions! It up to a stored internal command handler to handle exceptions.

Specified by:
execute in interface Command
Returns:
a return code that indicates the execution result. It depends on the context what the exact meaning of the return code is, but usually the value 0 (zero) implies success.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object