com.googlepages.dronten.jripper.util
Class StreamThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.googlepages.dronten.jripper.util.BaseThread
          extended by com.googlepages.dronten.jripper.util.StreamThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ContentsParserThread, DummyParserThread, ErrorParserThread, ScanbusParserStderrThread, ScanbusParserStdinThread, StreamParserThread

public class StreamThread
extends BaseThread

Stream reader thread. For reading streams from process streams. A reader can also write data to another process.


Nested Class Summary
static class StreamThread.ReadType
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.io.BufferedInputStream aByteReader
           
protected  java.io.BufferedOutputStream aByteWriter
           
protected  java.io.BufferedReader aLineReader
           
 StreamThread.ReadType aType
           
 boolean aWrite
           
 
Fields inherited from class com.googlepages.dronten.jripper.util.BaseThread
aProgress, aRunning
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
StreamThread(Log log, Progress progress, StreamThread.ReadType readType, boolean write)
           
 
Method Summary
 void close()
          Close streams.
 void data(byte[] bytes, int size)
          Default action is to send bytes to process writer.
 void data(java.lang.String line)
          Default action is to send bytes to process writer.
 StreamThread.ReadType getType()
           
 boolean isWriting()
           
 void run()
          Run stream reader thread.
 void setByteReader(java.io.BufferedInputStream stream)
           
 void setByteWriter(java.io.BufferedOutputStream stream)
           
 void setLineReader(java.io.BufferedReader reader)
           
 void write(byte[] bytes, int size)
          Write bytes to output process.
 
Methods inherited from class com.googlepages.dronten.jripper.util.BaseThread
addLog, getLog, getTrackNum, hasFailed, setFailed, setLog, setTrackNum, stopLogging, stopRunning
 
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

aType

public StreamThread.ReadType aType

aWrite

public boolean aWrite

aByteWriter

protected java.io.BufferedOutputStream aByteWriter

aByteReader

protected java.io.BufferedInputStream aByteReader

aLineReader

protected java.io.BufferedReader aLineReader
Constructor Detail

StreamThread

public StreamThread(Log log,
                    Progress progress,
                    StreamThread.ReadType readType,
                    boolean write)
Parameters:
log -
readType -
write -
Method Detail

close

public void close()
Close streams.

Overrides:
close in class BaseThread

data

public void data(byte[] bytes,
                 int size)
          throws java.lang.Exception
Default action is to send bytes to process writer.

Parameters:
bytes -
size -
Throws:
java.lang.Exception

data

public void data(java.lang.String line)
          throws java.lang.Exception
Default action is to send bytes to process writer.

Parameters:
line -
Throws:
java.lang.Exception

getType

public StreamThread.ReadType getType()
Returns:
Get type of process thread

isWriting

public boolean isWriting()
Returns:
true if read stream will write to output stream.

run

public void run()
Run stream reader thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

setByteReader

public void setByteReader(java.io.BufferedInputStream stream)
Parameters:
stream -

setByteWriter

public void setByteWriter(java.io.BufferedOutputStream stream)
Parameters:
stream -

setLineReader

public void setLineReader(java.io.BufferedReader reader)
Parameters:
reader -

write

public void write(byte[] bytes,
                  int size)
           throws java.lang.Exception
Write bytes to output process.

Parameters:
bytes -
size -
Throws:
java.lang.Exception