|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
fr.lip6.sma.simulacion.app.CLIApplication
public class CLIApplication
Class for command line applications.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private sun.misc.SignalHandler |
mDefaultIntHandler
Default handler for the INT signal. |
private BufferedReader |
mInputReader
Input stream. |
private PrintStream |
mOutputPrinter
Output stream. |
private boolean |
mRunning
Boolean indicating we should exit the main loop. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
CLIApplication(String inName)
Constructor from a string. |
Method Summary | |
---|---|
protected void |
displayHelp(String inLine)
Display the help. |
protected void |
flush()
Flush stdout. |
protected void |
init()
Method called at the beginning of the application. |
protected void |
print(String inString)
Display a string on stdout. |
protected void |
println(String inLine)
Display a string on stdout. |
protected void |
printStackTrace(Throwable inThrowable)
Display an exception's stack trace. |
protected boolean |
processCommand(String inCommand,
String inLine)
Method called to process commands. |
private void |
prompt()
Display the prompt. |
protected void |
quit()
Method called to quit the application. |
void |
run()
Main loop of the thread. |
private void |
signalHandler(sun.misc.Signal inSignal)
Handler for the INT signal. |
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 |
---|
private final sun.misc.SignalHandler mDefaultIntHandler
private final BufferedReader mInputReader
private final PrintStream mOutputPrinter
private boolean mRunning
Constructor Detail |
---|
public CLIApplication(String inName)
inName
- name for the thread.Method Detail |
---|
public final void run()
run
in interface Runnable
run
in class Thread
protected void init()
protected void quit()
protected boolean processCommand(String inCommand, String inLine)
protected boolean processCommand(String inCommand, String inLine) {
boolean theResult = super.processCommand(inCommand, inLine);
if (!theResult) {
theResult = true;
if ("FOO".equals(inCommand)) {
...
} else if ("BAR".equals(inCommand)) {
...
} else {
// Unknown command.
theResult = false;
}
}
return theResult;
}
inCommand
- command to parse (in uppercase).inLine
- the full line.
false
if the command was unknown, true
otherwise.protected void displayHelp(String inLine)
inLine
- line for the help command (unused).protected final void println(String inLine)
inLine
- line to display.protected final void print(String inString)
inString
- string to display.protected final void flush()
protected final void printStackTrace(Throwable inThrowable)
inThrowable
- throwable which stack trace to display.private void signalHandler(sun.misc.Signal inSignal)
inSignal
- received signal (INT).private void prompt()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |