console
Class SimpleOutputStreamTask

java.lang.Object
  extended by java.lang.Thread
      extended by console.StreamTask
          extended by console.SimpleOutputStreamTask
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ParsingOutputStreamTask

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) } }


Nested Class Summary
static class SimpleOutputStreamTask.WLTypes
          Types of waiting loop.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int BufferSize
           
protected  java.awt.Color defaultColor
           
protected  java.io.InputStream in
           
protected  java.lang.StringBuilder lineBuffer
           
protected  Output output
           
protected  int SleepDelayMSec
           
 
Fields inherited from class console.StreamTask
abortFlag, finishFlag
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimpleOutputStreamTask(java.io.InputStream in, Output output, java.awt.Color defaultColor)
           
 
Method Summary
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.
 
Methods inherited from class console.StreamTask
abort, finish
 
Methods inherited from class java.lang.Thread
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BufferSize

protected int BufferSize

SleepDelayMSec

protected int SleepDelayMSec

in

protected java.io.InputStream in

defaultColor

protected java.awt.Color defaultColor

output

protected Output output

lineBuffer

protected java.lang.StringBuilder lineBuffer
Constructor Detail

SimpleOutputStreamTask

public SimpleOutputStreamTask(java.io.InputStream in,
                              Output output,
                              java.awt.Color defaultColor)
Method Detail

actionInsideWaitingLoop

protected void actionInsideWaitingLoop(java.io.InputStreamReader isr)
                                throws java.lang.Exception
Run waiting loop inside.

Throws:
java.lang.Exception

afterWorking

protected void afterWorking()
                     throws java.lang.Exception
Run AFTER: - main working loop ends - "finalOutputing()" method (under "try" section)

Throws:
java.lang.Exception

beforeWorking

protected void beforeWorking()
                      throws java.lang.Exception
Run BEFORE main working loop starts (under "try" section)

Throws:
java.lang.Exception

finalOutputting

protected void finalOutputting()
Dump remained data from internal buffer "lineBuffer" to output "output" with color "defaultColor". Run AFTER main working loop ends, but BEFORE "afterWorking()" method. (under "finally" section)


exception_dumpToLog

protected void exception_dumpToLog(java.lang.Exception e)
By default dump data about exception to jEdit.Log BEFORE "exception_dumpToOwner()" method (under "catch" section)


exception_dumpToOwner

protected void exception_dumpToOwner(java.lang.Exception e)
By default do nothing AFTER "exception_dumpToLog" method (under "catch" section)


run

public final void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

outputData

protected void outputData()
                   throws java.lang.Exception
- Dump collected data from internal buffer "lineBuffer" to output "output" with color "defaultColor" - Clean internal buffer "lineBuffer" (under "try" section)

Throws:
java.lang.Exception

setWaitingLoop

public void setWaitingLoop(SimpleOutputStreamTask.WLTypes wl)
Setup waiting loop. Output handler reads data from external stream inside this loop.