simulator
Class ClientCommand

java.lang.Object
  |
  +--simulator.ClientCommand
Direct Known Subclasses:
AddClientCommand, DelClientCommand, ExitClientCommand, HelpClientCommand, ModifyClientCommand, NameClientCommand, WhoClientCommand

abstract class ClientCommand
extends java.lang.Object

This abstract class execute a command that the client write in the applet. To do this, you must derived it and implements the runCommand method. All the client commands that you build are manage by clientCommands hashtable of Server.

See Also:
Server.clientCommands

Field Summary
protected  java.lang.String command
          Contain the command as text help string like "ADD : adding a ..."
protected  java.lang.String description
          Contain the extended description of the command with the meanings of the parameters like "ADD param1 param2 \n param1=...
protected  java.lang.String name
          contain the name of command used as key by hashtable
 
Constructor Summary
ClientCommand(java.lang.String comm, java.lang.String desc)
          Constructor that initialize the ClientCommand:
 
Method Summary
 java.lang.String getDescription()
          Return an extended description of command
 java.lang.String getName()
          Return the name of the command; it must be used for the hashtable hash value.
 java.lang.String getText()
          Return the text description of the command.
abstract  boolean runCommand(java.util.StringTokenizer ST, Connection connection)
          This is the abstract method to implements that execute your command.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

command

protected java.lang.String command
Contain the command as text help string like "ADD : adding a ..."

description

protected java.lang.String description
Contain the extended description of the command with the meanings of the parameters like "ADD param1 param2 \n param1=... \n param2=..."

name

protected java.lang.String name
contain the name of command used as key by hashtable
Constructor Detail

ClientCommand

public ClientCommand(java.lang.String comm,
                     java.lang.String desc)
Constructor that initialize the ClientCommand:
Parameters:
comm - the text help string
desc - the extended description of command
Method Detail

getName

public java.lang.String getName()
Return the name of the command; it must be used for the hashtable hash value.
Returns:
the name of command as one token of a string

getText

public java.lang.String getText()
Return the text description of the command.
Returns:
the text string

getDescription

public java.lang.String getDescription()
Return an extended description of command
Returns:
the description

runCommand

public abstract boolean runCommand(java.util.StringTokenizer ST,
                                   Connection connection)
This is the abstract method to implements that execute your command. It received the StringTokenizer line that the client had insert, so you can extract your parameter.
Parameters:
ST - the line passed by client
connection - a copy of Connection istance to permit you to use it's variables
Returns:
a boolean that indicate if we must exit from RunCommand of Connection