de.uniba.wiai.lspi.util.console
Class Command

java.lang.Object
  extended by de.uniba.wiai.lspi.util.console.Command
Direct Known Subclasses:
ChangeProtocol, CrashNodes, CreateNodes, ExecuteMacro, Exit, Help, Insert, InsertNetwork, JoinNetwork, LeaveNetwork, Remove, RemoveNetwork, Retrieve, RetrieveNetwork, ShowEntries, ShowEntriesNetwork, ShowFingerTable, ShowFingerTableNetwork, ShowNodes, ShowOutputCommand, ShowSuccessorList, ShutdownNodes, Wait

public abstract class Command
extends java.lang.Object

Version:
1.0.5
Author:
sven

Constructor Summary
Command(java.lang.Object[] toCommand, java.io.PrintStream out)
          Creates a new instance of Command.
 
Method Summary
 void addParameter(java.lang.String paramName, java.lang.String paramValue)
          Add a command line parameter.
abstract  void exec()
          To be overwritten by subclasses for command execution.
 void execute()
          Executes the command.
abstract  java.lang.String getCommandName()
          Return the name of the command.
abstract  void printOutHelp()
          To be overwritten.
 void setParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
          Set the parameters for the Command.
 void setPrintStream(java.io.PrintStream out)
          Set the PrintStream, to that this command prints its output.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command(java.lang.Object[] toCommand,
               java.io.PrintStream out)
Creates a new instance of Command.

Parameters:
out - The java.io.PrintStream to that the command's output is printed.
toCommand - The instance to execute the command on.
Method Detail

setPrintStream

public void setPrintStream(java.io.PrintStream out)
Set the PrintStream, to that this command prints its output.

Parameters:
out - The PrintStream.

addParameter

public final void addParameter(java.lang.String paramName,
                               java.lang.String paramValue)
Add a command line parameter.

Parameters:
paramName - The parameters name. Cannot contain spaces.
paramValue - The parameters value. Cannot contain spaces.

execute

public final void execute()
                   throws ConsoleException
Executes the command.

Throws:
ConsoleException - Exception during execution of command.

exec

public abstract void exec()
                   throws ConsoleException
To be overwritten by subclasses for command execution. The work of a command implementation is done in this method.

Throws:
ConsoleException - Exception during execution.

printOutHelp

public abstract void printOutHelp()
To be overwritten. Display the help text of the Command.


getCommandName

public abstract java.lang.String getCommandName()
Return the name of the command. Must not contain spaces. To be overwritten by subclasses.

Returns:
The commands name. For example: exit.

setParameters

public void setParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
Set the parameters for the Command.

Parameters:
parameters - Hashtable containing the parameter names as keys and the parameter values as values. Both represented as Strings. Both must not contain spaces.