org.aitools.programd.interfaces.shell
Class ShellCommand

java.lang.Object
  extended by org.aitools.programd.interfaces.shell.ShellCommand
Direct Known Subclasses:
AIMLCommand, BotListCommand, CategoriesCommand, HelpCommand, ListBotFilesCommand, ListCommandablesCommand, LoadCommand, MemoryCommand, TalkToCommand, TestCommand, UnloadCommand, WhoCommand

public abstract class ShellCommand
extends java.lang.Object

A ShellCommand is a command that can be executed from the Shell.

Author:
Noel Bush

Field Summary
private  java.lang.String argumentTemplate
          The argument template for the shell command (so it can be returned via a get method).
private  java.lang.String commandString
          The command string for the shell command (so it can be returned via a get method).
private  java.lang.String helpLine
          The help line for the shell command (so it can be returned via a get method).
 
Constructor Summary
ShellCommand(java.lang.String commandStringToUse, java.lang.String argumentTemplateToUse, java.lang.String helpLineToUse)
          Creates a ShellCommand that handles the given command string.
 
Method Summary
 java.lang.String getArgumentTemplate()
          Returns the argument template for this command.
 java.lang.String getCommandString()
          Returns the command to which this responds.
 java.lang.String getHelpLine()
          Returns a line of help for this command.
abstract  void handle(java.lang.String commandLine, Shell shell)
          Handles the given command line.
abstract  boolean handles(java.lang.String commandLine)
          Indicates whether the ShellCommand handles a command contained in the given line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandString

private java.lang.String commandString
The command string for the shell command (so it can be returned via a get method).


argumentTemplate

private java.lang.String argumentTemplate
The argument template for the shell command (so it can be returned via a get method).


helpLine

private java.lang.String helpLine
The help line for the shell command (so it can be returned via a get method).

Constructor Detail

ShellCommand

public ShellCommand(java.lang.String commandStringToUse,
                    java.lang.String argumentTemplateToUse,
                    java.lang.String helpLineToUse)
Creates a ShellCommand that handles the given command string.

Parameters:
commandStringToUse - the command string to handle
argumentTemplateToUse - the argument template to use
helpLineToUse - the help line to provide when asked
Method Detail

handles

public abstract boolean handles(java.lang.String commandLine)
Indicates whether the ShellCommand handles a command contained in the given line.

Parameters:
commandLine - the line of text received
Returns:
whether the ShellCommand handles this

getCommandString

public java.lang.String getCommandString()
Returns the command to which this responds.

Returns:
the command to which this responds

getArgumentTemplate

public java.lang.String getArgumentTemplate()
Returns the argument template for this command.

Returns:
the argument template for this command

getHelpLine

public java.lang.String getHelpLine()
Returns a line of help for this command.

Returns:
a line of help for this command

handle

public abstract void handle(java.lang.String commandLine,
                            Shell shell)
Handles the given command line.

Parameters:
commandLine - the command line to handle
shell - the shell that got the command