Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

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

Inheritance diagram for org.objectweb.cjdbc.console.text.module.AbstractConsoleModule:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.console.text.module.AbstractConsoleModule:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AbstractConsoleModule (Console console)
abstract String getDescriptionString ()
void help ()
void quit ()
TreeSet getCommands ()
abstract String getPromptString ()
void handlePrompt ()
final Hashtable getHashCommands ()
final void handleCommandLine (String commandLine, Hashtable hashCommands) throws Exception
final void manageHistory (String command)
abstract void login (String[] params) throws Exception
Console getConsole ()
LinkedList getHistory ()

Protected Member Functions

abstract void loadCommands ()
void loadCompletor ()

Package Attributes

Console console
TreeSet commands
boolean quit
LinkedList history

Detailed Description

This class defines a AbstractConsoleModule

Author:
Nicolas Modrzyk

Mathieu Peltier

Version:
1.0

Definition at line 51 of file AbstractConsoleModule.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.AbstractConsoleModule Console  console  ) 
 

Creates a new AbstractConsoleModule.java object

Parameters:
console to refer from

Definition at line 64 of file AbstractConsoleModule.java.

References org.objectweb.cjdbc.console.text.Console.println().

00065   {
00066     this.console = console;
00067     this.commands = new TreeSet();
00068     this.history = new LinkedList();
00069     commands.add(new Help(this));
00070     commands.add(new History(this));
00071     commands.add(new Quit(this));
00072     console.println(ConsoleTranslate.get("module.loading",
00073         getDescriptionString()));
00074     this.loadCommands();
00075     this.loadCompletor();
00076   }


Member Function Documentation

TreeSet org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getCommands  ) 
 

Get all the commands for this module

Returns:
TreeSet of commands (commandName|commandObject)

Definition at line 136 of file AbstractConsoleModule.java.

00137   {
00138     return commands;
00139   }

Console org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getConsole  ) 
 

Get access to the console

Returns:
Console instace

Definition at line 273 of file AbstractConsoleModule.java.

00274   {
00275     return console;
00276   }

abstract String org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getDescriptionString  )  [pure virtual]
 

Text description of this module

Returns:
String description to display

Implemented in org.objectweb.cjdbc.console.text.module.ControllerConsole, org.objectweb.cjdbc.console.text.module.MonitorConsole, org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin, and org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

final Hashtable org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getHashCommands  ) 
 

Get the list of commands as strings for this module

Returns:
Hashtable list of String objects

Definition at line 195 of file AbstractConsoleModule.java.

References org.objectweb.cjdbc.console.text.commands.ConsoleCommand.getCommandName().

Referenced by org.objectweb.cjdbc.console.text.commands.History.parse().

00196   {
00197     Hashtable hashCommands = new Hashtable();
00198     ConsoleCommand consoleCommand;
00199     Iterator it = commands.iterator();
00200     while (it.hasNext())
00201     {
00202       consoleCommand = (ConsoleCommand) it.next();
00203       hashCommands.put(consoleCommand.getCommandName(), consoleCommand);
00204     }
00205     return hashCommands;
00206   }

LinkedList org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getHistory  ) 
 

Returns the history value.

Returns:
Returns the history.

Definition at line 283 of file AbstractConsoleModule.java.

Referenced by org.objectweb.cjdbc.console.text.commands.History.parse().

00284   {
00285     return history;
00286   }

abstract String org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.getPromptString  )  [pure virtual]
 

Get the prompt string for this module

Returns:
String to place before prompt

Implemented in org.objectweb.cjdbc.console.text.module.ControllerConsole, org.objectweb.cjdbc.console.text.module.MonitorConsole, org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin, and org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

final void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.handleCommandLine String  commandLine,
Hashtable  hashCommands
throws Exception
 

Handle module command

Parameters:
commandLine the command line to handle
hashCommands the list of commands available for this module
Exceptions:
Exception if fails

Definition at line 215 of file AbstractConsoleModule.java.

References org.objectweb.cjdbc.console.text.commands.ConsoleCommand.execute(), and org.objectweb.cjdbc.console.text.Console.printError().

Referenced by org.objectweb.cjdbc.console.text.commands.History.parse().

00217   {
00218     ConsoleCommand consoleCommand;
00219     StringTokenizer st = new StringTokenizer(commandLine);
00220     if (!st.hasMoreTokens())
00221     {
00222       console.printError(ConsoleTranslate.get("module.command.not.supported",
00223           ""));
00224       return;
00225     }
00226     String command = st.nextToken();
00227     consoleCommand = null; // reinit
00228     try
00229     {
00230       consoleCommand = (ConsoleCommand) hashCommands.get(command);
00231     }
00232     catch (NoSuchElementException e)
00233     {
00234       consoleCommand = null;
00235     }
00236     if (consoleCommand == null)
00237     {
00238       console.printError(ConsoleTranslate.get("module.command.not.supported",
00239           command));
00240     }
00241     else
00242     {
00243       consoleCommand.execute(commandLine.substring(command.length()));
00244     }
00245   }

void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.handlePrompt  ) 
 

Handle a serie of commands

Reimplemented in org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

Definition at line 151 of file AbstractConsoleModule.java.

References org.objectweb.cjdbc.console.text.Console.printError(), and org.objectweb.cjdbc.console.text.Console.readLine().

00152   {
00153     if (quit)
00154     {
00155       console.printError(ConsoleTranslate.get("module.quitting",
00156           getDescriptionString()));
00157       return;
00158     }
00159 
00160     Hashtable hashCommands = getHashCommands();
00161 
00162     //login();
00163     quit = false;
00164     while (!quit)
00165     {
00166       try
00167       {
00168         String commandLine = console.readLine(getPromptString());
00169         if (commandLine == null)
00170         {
00171           quit = true;
00172           break;
00173         }
00174         if (commandLine.equals(""))
00175           continue;
00176         else
00177           manageHistory(commandLine);
00178 
00179         handleCommandLine(commandLine, hashCommands);
00180 
00181       }
00182       catch (Exception e)
00183       {
00184         console.printError(ConsoleTranslate.get("module.command.got.error",
00185             new Object[]{e.getClass(), e.getMessage()}), e);
00186       }
00187     }
00188   }

void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.help  ) 
 

Display help for this module

Reimplemented in org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

Definition at line 108 of file AbstractConsoleModule.java.

References org.objectweb.cjdbc.console.text.commands.ConsoleCommand.getCommandDescription(), org.objectweb.cjdbc.console.text.commands.ConsoleCommand.getCommandName(), org.objectweb.cjdbc.console.text.commands.ConsoleCommand.getCommandParameters(), org.objectweb.cjdbc.console.text.Console.printInfo(), and org.objectweb.cjdbc.console.text.Console.println().

Referenced by org.objectweb.cjdbc.console.text.commands.Help.parse().

00109   {
00110     console.println(ConsoleTranslate.get("module.commands.available",
00111         getDescriptionString()));
00112     ConsoleCommand command;
00113     Iterator it = commands.iterator();
00114     while (it.hasNext())
00115     {
00116       command = (ConsoleCommand) it.next();
00117       console.printInfo(command.getCommandName() + " "
00118           + command.getCommandParameters());
00119       console.println("   " + command.getCommandDescription());
00120     }
00121   }

abstract void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.loadCommands  )  [protected, pure virtual]
 

Loads the commands for this module

Implemented in org.objectweb.cjdbc.console.text.module.ControllerConsole, org.objectweb.cjdbc.console.text.module.MonitorConsole, org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin, and org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

abstract void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.login String[]  params  )  throws Exception [pure virtual]
 

Handles login in this module

Parameters:
params parameters to use to login in this module
Exceptions:
Exception if fails

Implemented in org.objectweb.cjdbc.console.text.module.ControllerConsole, org.objectweb.cjdbc.console.text.module.MonitorConsole, org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin, and org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

final void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.manageHistory 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

Definition at line 253 of file AbstractConsoleModule.java.

00254   {
00255     history.add(command);
00256     if (history.size() > HISTORY_MAX)
00257       history.removeFirst();
00258   }

void org.objectweb.cjdbc.console.text.module.AbstractConsoleModule.quit  ) 
 

Quit this module

Reimplemented in org.objectweb.cjdbc.console.text.module.ControllerConsole, and org.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole.

Definition at line 126 of file AbstractConsoleModule.java.

Referenced by org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin.login().

00127   {
00128     this.quit = true;
00129   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:09 2005 for C-JDBC by  doxygen 1.3.9.1