public class SimpleOutputStreamTask extends StreamTask
SimpleOutputStreamTask is a base outputting class. It gets a data from an external InputStream and dumps one to an external Output using a defaultColor. Main working method run() of this class is marked as final. On the other hand SimpleOutputStreamTask provides its descendants with a few methods, which descendants can override. Below these methods are shown inside the run() method's body run() { try { beforeWorking() try { MAIN-LOOP { try { WAITING-LOOP { // reading from InputStream isr // sleep actionInsideWaitingLoop(isr) } } catch (InterruptedException ie) { break // MAIN-LOOP } // lineBuffer's filling outputData() } } finally { finalOutputting() afterWorking() } } catch (Exception e) { exception_dumpToLog(e) exception_dumpToOwner(e) } }
Modifier and Type | Class and Description |
---|---|
static class |
SimpleOutputStreamTask.WLTypes
Types of waiting loop.
|
Modifier and Type | Field and Description |
---|---|
protected int |
BufferSize |
protected java.awt.Color |
defaultColor |
protected java.io.InputStream |
in |
protected java.lang.StringBuilder |
lineBuffer |
protected Output |
output |
protected int |
SleepDelayMSec |
abortFlag, finishFlag
Constructor and Description |
---|
SimpleOutputStreamTask(java.io.InputStream in,
Output output,
java.awt.Color defaultColor) |
Modifier and Type | Method and Description |
---|---|
protected void |
actionInsideWaitingLoop(java.io.InputStreamReader isr)
Run waiting loop inside.
|
protected void |
afterWorking()
Run AFTER:
- main working loop ends
- "finalOutputing()" method
(under "try" section)
|
protected void |
beforeWorking()
Run BEFORE main working loop starts
(under "try" section)
|
protected void |
exception_dumpToLog(java.lang.Exception e)
By default dump data about exception to jEdit.Log
BEFORE "exception_dumpToOwner()" method
(under "catch" section)
|
protected void |
exception_dumpToOwner(java.lang.Exception e)
By default do nothing AFTER "exception_dumpToLog" method
(under "catch" section)
|
protected void |
finalOutputting()
Dump remained data from internal buffer "lineBuffer"
to output "output" with color "defaultColor".
|
protected void |
outputData()
- Dump collected data from internal buffer "lineBuffer"
to output "output" with color "defaultColor"
- Clean internal buffer "lineBuffer"
(under "try" section)
|
void |
run() |
void |
setWaitingLoop(SimpleOutputStreamTask.WLTypes wl)
Setup waiting loop.
|
abort, finish
activeCount, checkAccess, clone, 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
protected int BufferSize
protected int SleepDelayMSec
protected java.io.InputStream in
protected java.awt.Color defaultColor
protected Output output
protected java.lang.StringBuilder lineBuffer
public SimpleOutputStreamTask(java.io.InputStream in, Output output, java.awt.Color defaultColor)
protected void actionInsideWaitingLoop(java.io.InputStreamReader isr) throws java.lang.Exception
java.lang.Exception
protected void afterWorking() throws java.lang.Exception
java.lang.Exception
protected void beforeWorking() throws java.lang.Exception
java.lang.Exception
protected void finalOutputting()
protected void exception_dumpToLog(java.lang.Exception e)
protected void exception_dumpToOwner(java.lang.Exception e)
public final void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void outputData() throws java.lang.Exception
java.lang.Exception
public void setWaitingLoop(SimpleOutputStreamTask.WLTypes wl)