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 |
Definition at line 51 of file AbstractConsoleModule.java.
|
Creates a new
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 }
|
|
Get all the commands for this module
Definition at line 136 of file AbstractConsoleModule.java. 00137 {
00138 return commands;
00139 }
|
|
Get access to the console
Definition at line 273 of file AbstractConsoleModule.java. 00274 {
00275 return console;
00276 }
|
|
Text description of 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. |
|
Get the list of commands as strings for this module
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 }
|
|
Returns the history value.
Definition at line 283 of file AbstractConsoleModule.java. Referenced by org.objectweb.cjdbc.console.text.commands.History.parse(). 00284 {
00285 return history;
00286 }
|
|
Get the prompt string 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. |
|
Handle module command
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 }
|
|
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 }
|
|
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 }
|
|
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. |
|
Handles login in 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. |
|
Add the command to the history. Removes the first item in the list if the history is too large.
Definition at line 253 of file AbstractConsoleModule.java. 00254 {
00255 history.add(command);
00256 if (history.size() > HISTORY_MAX)
00257 history.removeFirst();
00258 }
|
|
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 }
|