org.objectweb.cjdbc.console.text.module
Class AbstractConsoleModule

java.lang.Object
  extended byorg.objectweb.cjdbc.console.text.module.AbstractConsoleModule
Direct Known Subclasses:
ControllerConsole, MonitorConsole, VirtualDatabaseAdmin, VirtualDatabaseConsole

public abstract class AbstractConsoleModule
extends java.lang.Object

This class defines a AbstractConsoleModule

Version:
1.0
Author:
Nicolas Modrzyk , Mathieu Peltier

Nested Class Summary
(package private)  class AbstractConsoleModule.CommandDelimiter
          This class defines a CommandDelimiter used to delimit a command from user input
 
Field Summary
(package private)  java.util.TreeSet commands
           
(package private)  Console console
           
protected  jline.Completor consoleCompletor
           
(package private)  java.util.LinkedList history
           
private static int HISTORY_MAX
           
(package private)  boolean quit
           
 
Constructor Summary
AbstractConsoleModule(Console console)
          Creates a new AbstractConsoleModule.java object
 
Method Summary
 ConsoleCommand findConsoleCommand(java.lang.String commandLine, java.util.Hashtable hashCommands)
          Find the ConsoleCommand based on the name of the command from the commandLine in the hashCommands.
 java.util.TreeSet getCommands()
          Get all the commands for this module
 jline.Completor getCompletor()
          Returns the console completor to use for this module.
 Console getConsole()
          Get access to the console
abstract  java.lang.String getDescriptionString()
          Text description of this module
 java.util.Hashtable getHashCommands()
          Get the list of commands as strings for this module
 java.util.LinkedList getHistory()
          Returns the history value.
abstract  java.lang.String getPromptString()
          Get the prompt string for this module
 void handleCommandLine(java.lang.String commandLine, java.util.Hashtable hashCommands)
          Handle module command
 void handlePrompt()
          Handle a serie of commands
 void help()
          Display help for this module
protected abstract  void loadCommands()
          Loads the commands for this module
protected  void loadCompletor()
          Loads the commands for this module
protected  void loadHistory()
          Load History from java Preferences
abstract  void login(java.lang.String[] params)
          Handles login in this module
 void manageHistory(java.lang.String command)
          Add the command to the history.
 void quit()
          Quit this module
protected  void reloadCompletor()
          Reload the completor associated with this module.
protected  void storeHistory()
          Strore History to java Preferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HISTORY_MAX

private static final int HISTORY_MAX
See Also:
Constant Field Values

console

Console console

commands

java.util.TreeSet commands

quit

boolean quit

history

java.util.LinkedList history

consoleCompletor

protected jline.Completor consoleCompletor
Constructor Detail

AbstractConsoleModule

public AbstractConsoleModule(Console console)
Creates a new AbstractConsoleModule.java object

Parameters:
console - to refer from
Method Detail

loadCommands

protected abstract void loadCommands()
Loads the commands for this module


loadCompletor

protected void loadCompletor()
Loads the commands for this module


reloadCompletor

protected void reloadCompletor()
Reload the completor associated with this module. This method must be called if the list of commands has been dynamically modified.


getDescriptionString

public abstract java.lang.String getDescriptionString()
Text description of this module

Returns:
String description to display

help

public void help()
Display help for this module


quit

public void quit()
Quit this module


loadHistory

protected void loadHistory()
Load History from java Preferences


storeHistory

protected void storeHistory()
Strore History to java Preferences


getCommands

public java.util.TreeSet getCommands()
Get all the commands for this module

Returns:
TreeSet of commands (commandName|commandObject)

getPromptString

public abstract java.lang.String getPromptString()
Get the prompt string for this module

Returns:
String to place before prompt

handlePrompt

public void handlePrompt()
Handle a serie of commands


getHashCommands

public final java.util.Hashtable getHashCommands()
Get the list of commands as strings for this module

Returns:
Hashtable list of String objects

handleCommandLine

public final void handleCommandLine(java.lang.String commandLine,
                                    java.util.Hashtable hashCommands)
                             throws java.lang.Exception
Handle module command

Parameters:
commandLine - the command line to handle
hashCommands - the list of commands available for this module
Throws:
java.lang.Exception - if fails *

findConsoleCommand

public ConsoleCommand findConsoleCommand(java.lang.String commandLine,
                                         java.util.Hashtable hashCommands)
Find the ConsoleCommand based on the name of the command from the commandLine in the hashCommands. If more than one ConsoleCommand's command name start the same way, return the ConsoleCommand with the longest one.

Parameters:
commandLine - the command line to handle
hashCommands - the list of commands available for this module
Returns:
the ConsoleCommand corresponding to the name of the command from the commandLine or null if there is no matching

manageHistory

public final void manageHistory(java.lang.String command)
Add the command to the history. Removes the first item in the list if the history is too large.

Parameters:
command - taken from the command line

login

public abstract void login(java.lang.String[] params)
                    throws java.lang.Exception
Handles login in this module

Parameters:
params - parameters to use to login in this module
Throws:
java.lang.Exception - if fails

getConsole

public Console getConsole()
Get access to the console

Returns:
Console instance

getHistory

public java.util.LinkedList getHistory()
Returns the history value.

Returns:
Returns the history.

getCompletor

public jline.Completor getCompletor()
Returns the console completor to use for this module.

Returns:
Completor object.


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.