|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bluemarsh.jswat.DefaultManager | +--com.bluemarsh.jswat.CommandManager
Class CommandManager is responsible for parsing text-based commands entered by the user. It breaks up the input into tokens and determines which command is to be executed. It then calls on the appropriate command object to perform the action.
Field Summary | |
protected java.util.Hashtable |
aliasList
Table of command aliases, keyed by their alias name. |
protected java.util.Hashtable |
commandList
Table of commands keyed by their action command string. |
protected java.util.ArrayList |
commandNames
Sorted list of all command names. |
protected int |
currentHistory
Index into historyChain indicating current old command being examined by the user. |
protected JSwatCommand |
grabInputCommand
Command object that wishes to grab the next input. |
protected java.util.LinkedList |
historyChain
List of commands executed by the user, stored in order. |
protected MacroManager |
macroManager
Reference to the manager of macros. |
protected Log |
outputLog
Log to write to when commands perform their tasks or have errors to report. |
protected Session |
owningSession
JSwat session that we're associated with. |
Fields inherited from class com.bluemarsh.jswat.DefaultManager |
swat |
Constructor Summary | |
CommandManager()
Constructs a CommandManager with the default input field. |
Method Summary | |
protected java.lang.String |
checkPrefix(java.lang.String input)
Check for a possible matching command prefix. |
void |
createAlias(java.lang.String name,
java.lang.String cmnd)
Creates a command alias. |
void |
displayHistory()
Displays a list of the commands in the history chain to the main message window. |
protected java.lang.Class |
findCommand(java.lang.String commandName)
Find the class of the command, given the command name. |
java.lang.String |
getAlias(java.lang.String name)
Returns the definition of the named alias. |
JSwatCommand |
getCommand(java.lang.String commandName)
Fetches an instance of the command by the given name. |
java.lang.String |
getHistoryNext()
Retrieves the command following the current position within the command history. |
java.lang.String |
getHistoryPrev()
Retrieves the command preceeding the current position within the command history. |
void |
grabInput(JSwatCommand command)
Tell the CommandManager that the given command should be passed the next input from the user. |
void |
handleInput(java.lang.String inputStr)
Parse the input and execute the command. |
protected boolean |
handleInputGrab(java.lang.String inputStr)
Handle the input grab of some arbitrary command. |
void |
init(Session session)
Called after the Session has instantiated this mananger. |
void |
listAliases()
List all of the created command aliases to the main message window. |
void |
listCommands()
List all of the loaded commands with a brief description of each. |
void |
listMacros()
List all of the created command macros to the main message window. |
protected java.lang.String |
parseBang(java.lang.String inputStr)
Handle the '!' and '!!' operators by looking for a matching command in the command history and returning the input string to be executed. |
void |
parseInput(java.lang.String inputStr)
Parse the command input string and perform the appropriate action. |
void |
removeAlias(java.lang.String alias)
Remove the specified alias. |
protected void |
runCommand(java.lang.String inputStr)
Runs the given command input, without handling '!' or command aliases. |
void |
runScript(java.lang.String filepath)
Read the lines from the given file and parse each line as if it were a command. |
Methods inherited from class com.bluemarsh.jswat.DefaultManager |
activate, close, deactivate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Hashtable commandList
protected java.util.ArrayList commandNames
protected java.util.Hashtable aliasList
protected Log outputLog
protected Session owningSession
protected java.util.LinkedList historyChain
protected int currentHistory
protected JSwatCommand grabInputCommand
grabInput()
method and reset
by handleInputGrab()
.protected MacroManager macroManager
Constructor Detail |
public CommandManager()
Method Detail |
protected java.lang.String checkPrefix(java.lang.String input) throws com.bluemarsh.jswat.CommandManager.AmbiguousMatchException
input
- possible command prefix to look for.AmbiguousMatchException
- Thrown if the input matched more than one command.public void createAlias(java.lang.String name, java.lang.String cmnd)
name
- Name of new alias.cmnd
- Command string to alias.public void displayHistory()
protected java.lang.Class findCommand(java.lang.String commandName)
commandName
- Name of command to find.public java.lang.String getAlias(java.lang.String name)
name
- alias name.public JSwatCommand getCommand(java.lang.String commandName)
commandName
- Name of command to fetch.public java.lang.String getHistoryNext()
public java.lang.String getHistoryPrev()
public void grabInput(JSwatCommand command)
receiveInput()
method of the
command. Subsequent user input will be processed normally.public void handleInput(java.lang.String inputStr)
inputStr
- command input.protected boolean handleInputGrab(java.lang.String inputStr)
inputStr
- Command input string.public void init(Session session)
Session.getManager()
.init
in class DefaultManager
session
- Session initializing this manager.public void listAliases()
public void listCommands()
public void listMacros()
protected java.lang.String parseBang(java.lang.String inputStr)
inputStr
- Command input string.public void parseInput(java.lang.String inputStr)
inputStr
- Input command string.public void removeAlias(java.lang.String alias)
alias
- Name of alias to remove.protected void runCommand(java.lang.String inputStr)
inputStr
- Original command input string.public void runScript(java.lang.String filepath)
filepath
- Path and filename of script file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |