org.objectweb.cjdbc.controller.console
Class CommandLineConsoleHelper

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.console.CommandLineConsoleHelper
All Implemented Interfaces:
ConsoleHelperInterface

public class CommandLineConsoleHelper
extends java.lang.Object
implements ConsoleHelperInterface

Command line console helper. This class is a simply implementation of the ConsoleHelperInterface interface. If you want to beneficiate of advanced features (such as command completion, command historic, possibility to hide password, ...), use the GUIConsoleHelper class. These features are impossible to obtain in pure Java. Native code must be used and for example the java-readline project (http://java-readline.sf.net/).

Version:
1.0
Author:
Mathieu Peltier

Field Summary
private  java.io.BufferedReader inbuf
          BufferedReader allowing to reading input.
private  boolean interactive
          true if the console is used in interactive mode.
 
Constructor Summary
CommandLineConsoleHelper(java.io.InputStream in, boolean interactive)
          Creates a new CommandLineConsoleHelper instance reading from a given InputStream.
 
Method Summary
 void print(java.lang.String s)
          Prints a String.
 void printError(java.lang.String message)
          Prints an error message followed by a new line.
 void println()
          Prints a new line.
 void println(java.lang.String s)
          Prints a String followed by a new line.
 java.lang.String readLine(java.lang.String prompt)
          Gets a command.
 java.lang.String readPassword(java.lang.String prompt)
          Gets a password.
 void setCommandCompletor(CommandCompletorInterface commandCompletor)
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inbuf

private java.io.BufferedReader inbuf
BufferedReader allowing to reading input.


interactive

private boolean interactive
true if the console is used in interactive mode.

Constructor Detail

CommandLineConsoleHelper

public CommandLineConsoleHelper(java.io.InputStream in,
                                boolean interactive)
Creates a new CommandLineConsoleHelper instance reading from a given InputStream.

Parameters:
in - an InputStream instance.
interactive - true if the console is used in interactive mode.
Method Detail

readLine

public java.lang.String readLine(java.lang.String prompt)
                          throws ConsoleHelperException
Description copied from interface: ConsoleHelperInterface
Gets a command.

Specified by:
readLine in interface ConsoleHelperInterface
Parameters:
prompt - the prompt to display
Returns:
a String instance
Throws:
ConsoleHelperException - if an error occurs.
See Also:
ConsoleHelperInterface.readLine(java.lang.String)

readPassword

public java.lang.String readPassword(java.lang.String prompt)
                              throws ConsoleHelperException
Description copied from interface: ConsoleHelperInterface
Gets a password. If possible the implementation class should not displayed the data entered by the user.

Specified by:
readPassword in interface ConsoleHelperInterface
Parameters:
prompt - the prompt to display
Returns:
a String instance
Throws:
ConsoleHelperException - if an error occurs.
See Also:
ConsoleHelperInterface.readPassword(java.lang.String)

print

public void print(java.lang.String s)
Description copied from interface: ConsoleHelperInterface
Prints a String.

Specified by:
print in interface ConsoleHelperInterface
Parameters:
s - the String to print.
See Also:
ConsoleHelperInterface.print(java.lang.String)

println

public void println(java.lang.String s)
Description copied from interface: ConsoleHelperInterface
Prints a String followed by a new line.

Specified by:
println in interface ConsoleHelperInterface
Parameters:
s - the String to print.
See Also:
ConsoleHelperInterface.println(java.lang.String)

println

public void println()
Description copied from interface: ConsoleHelperInterface
Prints a new line.

Specified by:
println in interface ConsoleHelperInterface
See Also:
ConsoleHelperInterface.println()

printError

public void printError(java.lang.String message)
Description copied from interface: ConsoleHelperInterface
Prints an error message followed by a new line.

Specified by:
printError in interface ConsoleHelperInterface
Parameters:
message - the error message to print.
See Also:
ConsoleHelperInterface.printError(java.lang.String)

setCommandCompletor

public void setCommandCompletor(CommandCompletorInterface commandCompletor)
Not supported.

Specified by:
setCommandCompletor in interface ConsoleHelperInterface
Parameters:
commandCompletor - a CommandCompletor instance.
See Also:
ConsoleHelperInterface.setCommandCompletor(org.objectweb.cjdbc.controller.console.CommandCompletorInterface)


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