henplus
Class CommandDispatcher

java.lang.Object
  extended by henplus.CommandDispatcher

public class CommandDispatcher
extends Object

The Command Dispatcher for all commands.


Constructor Summary
CommandDispatcher(SetCommand sc)
           
 
Method Summary
 void addExecutionListener(ExecutionListener listener)
          Add an execution listener that is informed whenever a command is executed.
 String completer(String text, int state)
           
 boolean containsCommand(String cmd)
           
 void endBatch()
           
 void execute(SQLSession session, String givenCommand)
          execute the command given.
 Command getCommandFrom(String completeCmd)
           
 String getCommandNameFrom(String completeCmd)
          extracts the command from the commandstring.
 Iterator getRegisteredCommandNames()
          returns a sorted list of command names.
 Iterator getRegisteredCommandNames(String key)
          returns a sorted list of command names, starting with the first entry matching the key.
 Iterator getRegisteredCommands()
          returns the commands in the sequence they have been added.
 boolean isInBatch()
           
 void register(Command c)
           
 void registerAdditionalCommand(String cmd, Command c)
           
 boolean removeExecutionListener(ExecutionListener listener)
          remove an execution listener.
 void shutdown()
           
 void startBatch()
           
 void unregister(Command c)
          unregister command.
 void unregisterAdditionalCommand(String cmd)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandDispatcher

public CommandDispatcher(SetCommand sc)
Method Detail

getRegisteredCommands

public Iterator getRegisteredCommands()
returns the commands in the sequence they have been added.


getRegisteredCommandNames

public Iterator getRegisteredCommandNames()
returns a sorted list of command names.


getRegisteredCommandNames

public Iterator getRegisteredCommandNames(String key)
returns a sorted list of command names, starting with the first entry matching the key.


startBatch

public void startBatch()

endBatch

public void endBatch()

isInBatch

public boolean isInBatch()

register

public void register(Command c)

containsCommand

public boolean containsCommand(String cmd)

registerAdditionalCommand

public void registerAdditionalCommand(String cmd,
                                      Command c)

unregisterAdditionalCommand

public void unregisterAdditionalCommand(String cmd)

unregister

public void unregister(Command c)
unregister command. This is an 'expensive' operation, since we go through the internal list until we find the command and remove it. But since the number of commands is low and this is a rare operation (the plugin-mechanism does this) .. we don't care.


getCommandNameFrom

public String getCommandNameFrom(String completeCmd)
extracts the command from the commandstring. This even works, if there is not delimiter between the command and its arguments (this is esp. needed for the commands '?', '!', '@' and '@@').


getCommandFrom

public Command getCommandFrom(String completeCmd)

shutdown

public void shutdown()

addExecutionListener

public void addExecutionListener(ExecutionListener listener)
Add an execution listener that is informed whenever a command is executed.

Parameters:
listener - an Execution Listener

removeExecutionListener

public boolean removeExecutionListener(ExecutionListener listener)
remove an execution listener.

Parameters:
listener - the execution listener to be removed
Returns:
true, if this has been successful.

execute

public void execute(SQLSession session,
                    String givenCommand)
execute the command given. This strips whitespaces and trailing semicolons and calls the Command class.


completer

public String completer(String text,
                        int state)


? 1997..2006 Henner Zeller