ioutil
Class CommandTable

java.lang.Object
  |
  +--ioutil.CommandTable

public class CommandTable
extends java.lang.Object

A CommandTable provides a means for storing, retrieving, and executing commands for command-driven interpreter programs.


Constructor Summary
CommandTable()
          new CommandTable() returns a new empty CommandTable.
 
Method Summary
 void add(Command comm)
          ct.add(comm) adds comm to ct.
 void displayHelp(java.lang.String str)
          ct.displayHelp(String str) displays full descriptions for Commands in ct whose name matches str.
 void displayMenu()
          ct.displayMenu() displays a menu of commands in ct.
static Command doNothingCommand(java.lang.String str)
          CommandTable.doNothingCommand(str) returns a Command that does nothing.
 void execute(LineScanner commLine)
          ct.execute(commLine) executes the Command whose name is the first word of commLine and whose arguments are the remaining words of commLine.
 Command helpCommand(java.lang.String str)
          ct.helpCommand(str) returns a Command named str.
static Command quitCommand(java.lang.String str)
          CommandTable.quitCommand(str) returns a Command that terminates the program.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandTable

public CommandTable()
new CommandTable() returns a new empty CommandTable.
Method Detail

add

public void add(Command comm)
ct.add(comm) adds comm to ct.

Preconditions:
The name of comm is not an empty string.
The name of comm is not a prefix of the name of any Command in ct.
No name of a Command in ct is a prefix of the name of comm.


execute

public void execute(LineScanner commLine)
ct.execute(commLine) executes the Command whose name is the first word of commLine and whose arguments are the remaining words of commLine.

displayMenu

public void displayMenu()
ct.displayMenu() displays a menu of commands in ct.

displayHelp

public void displayHelp(java.lang.String str)
ct.displayHelp(String str) displays full descriptions for Commands in ct whose name matches str.

helpCommand

public Command helpCommand(java.lang.String str)
ct.helpCommand(str) returns a Command named str. If this Command is called with no arguments then it displays a menu of commands in ct. If it is called with one or more arguments then it displays full decriptions of commands in ct that match the arguments.

doNothingCommand

public static Command doNothingCommand(java.lang.String str)
CommandTable.doNothingCommand(str) returns a Command that does nothing. The command name for this Command is specified by str.

quitCommand

public static Command quitCommand(java.lang.String str)
CommandTable.quitCommand(str) returns a Command that terminates the program. The command name for this Command is specified by str.