|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
de.uniba.wiai.lspi.util.console.ConsoleThread
public class ConsoleThread
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected String |
consoleName
The name of this console. |
protected Command |
exitCommand
The Command that exits the console. |
protected CommandFactory |
factory
The factory responsible for Creation of commands. |
protected PrintStream |
out
The PrintStream to print the consoles output to. |
protected PrintStream |
systemOut
The old PrintStream to print the standard output to. |
protected OutputStream |
systemOutputStream
Reference to the standard output stream. |
protected String |
welcome
The text displayed, when the Thread is started. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
protected |
ConsoleThread(String name,
CommandFactory f)
Creates a new instance of ConsoleThread |
protected |
ConsoleThread(String name,
CommandFactory f,
OutputStream systemOut)
Creates a new instance of ConsoleThread. |
| Method Summary | |
|---|---|
CommandFactory |
getCommandFactory()
Get a reference to the CommandFactory used by this console. |
static ConsoleThread |
getConsole()
Method to obtain a reference to the console currently active in this JVM. |
static ConsoleThread |
getConsole(String name,
CommandFactory factory)
Factory method to get a reference to the console singleton. |
static ConsoleThread |
getConsole(String name,
CommandFactory factory,
OutputStream systemOut)
Factory method to create a console. |
PrintStream |
getPrintStream()
Get a reference to the PrintStream this console prints its output
to. |
OutputStream |
getSystemOutputStream()
Get a reference to the OutputStream calls to System.out are
delegated to. |
void |
run()
The run method. |
void |
setExitCommand(String commandName)
Set the Command that exits this console. |
void |
setWelcomeText(String text)
Set a costum welcome text for the console. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String consoleName
protected CommandFactory factory
protected String welcome
protected Command exitCommand
Command that exits the console. Its execute method is invoked
and the console exits.
protected PrintStream out
protected PrintStream systemOut
null
if this console does not change the standard output via constructor
ConsoleThread(String, CommandFactory).
protected OutputStream systemOutputStream
| Constructor Detail |
|---|
protected ConsoleThread(String name,
CommandFactory f)
name - The name of this console. Displayed before any input.f - The CommandFactory responsible for creating
Commands.
protected ConsoleThread(String name,
CommandFactory f,
OutputStream systemOut)
System.out is redirected to systemOut.
name - The name of this console. Displayed before any input.f - The CommandFactory responsible for creating
Commands.systemOut - The OutputStream to redirect standard ouput to. If you
do not want to have any output send to System.out, you can use
DummyOutputStream. If you want to save output send to
System.out in Memory to e.g. display it later you can use
MemoryOutputStream. To write output to a file you can
use FileOutputStream.| Method Detail |
|---|
public static ConsoleThread getConsole()
null, if there is none.
public static ConsoleThread getConsole(String name,
CommandFactory factory)
name - factory -
public static ConsoleThread getConsole(String name,
CommandFactory factory,
OutputStream systemOut)
name - factory - systemOut -
public PrintStream getPrintStream()
PrintStream this console prints its output
to.
PrintStream this console prints its
output to.public OutputStream getSystemOutputStream()
OutputStream calls to System.out are
delegated to. Returns null if System.out has not been
redirected.
OutputStream calls to System.out are
delegated to. Returns null if System.out has not
been redirected.public CommandFactory getCommandFactory()
CommandFactory used by this console.
CommandFactory used by this console.public void setWelcomeText(String text)
text - The welcome text to set.public void run()
run in interface Runnablerun in class Thread
public void setExitCommand(String commandName)
throws ConsoleException
Command that exits this console. Uses the
CommandFactory to create an instance of the Command.
commandName - The name of the command.
ConsoleException - Exception during creation of the command.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||