|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gshute.ioutil.CommandTable
A CommandTable provides a means for storing, retrieving, and executing commands for command-driven interpreter programs.
Field Summary | |
protected java.util.Vector |
commands
commands is the list of commands in this CommandTable. |
protected int |
maxNameLength
maxNameLength is the length of the longest command name in this CommandTable. |
protected int |
maxSynopsisLength
maxSynopsisLength is the length of the longest synopsis in this CommandTable. |
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. |
protected Command |
getCommand(java.lang.String str)
getCommand(str) returns the Command in this CommandTable whose name matches str. |
protected java.util.Enumeration |
getCommandsMatching(java.lang.String str)
getCommandsMatching(str) returns an Enumeration of Commands in this CommandTable whose names match str. |
Command |
helpCommand(java.lang.String str)
ct.helpCommand(str) returns a Command named str. |
protected int |
matchCount(java.lang.String str)
ct.matchCount(str) returns the number of Commands in ct whose name contains str as a prefix. |
protected int |
prefixCount(java.lang.String str)
ct.prefixCount(str) returns the number of Commands in ct whose name is a prefix of 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 |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.util.Vector commands
protected int maxNameLength
protected int maxSynopsisLength
Constructor Detail |
public CommandTable()
Method Detail |
public void add(Command comm)
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.
public void execute(LineScanner commLine)
public void displayMenu()
public void displayHelp(java.lang.String str)
public Command helpCommand(java.lang.String str)
public static Command doNothingCommand(java.lang.String str)
public static Command quitCommand(java.lang.String str)
protected int matchCount(java.lang.String str)
protected int prefixCount(java.lang.String str)
protected Command getCommand(java.lang.String str)
Precondition:
str is the name of a Command in ct.
protected java.util.Enumeration getCommandsMatching(java.lang.String str)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |