net.sourceforge.groboutils.util.thread.v1
Class IOThreadRunner

java.lang.Object
  extended bynet.sourceforge.groboutils.util.thread.v1.IOThreadRunner

public class IOThreadRunner
extends java.lang.Object

Loops, reading from the input stream and writes to the output stream.

Since:
November 17, 2000
Version:
$Date: 2003/02/10 22:52:48 $
Author:
Matt Albrecht groboclown@users.sourceforge.net
See Also:
LoopThread

Constructor Summary
IOThreadRunner(java.io.InputStream is, java.io.OutputStream os)
          Create a new ThreadRunner, re-routing is data into the os stream.
IOThreadRunner(LoopThread lt, java.io.InputStream is, java.io.OutputStream os)
          Create a new ThreadRunner, re-routing is data into the os stream, but uses the initialization of the given LoopThread.
 
Method Summary
 java.io.IOException getException()
          Retrieves the most recent exception that occured, if any.
 java.io.OutputStream getOutputStream()
          Retrieves the output stream that the input is redirected to.
 LoopThread getThread()
          Retrieves the LoopThread instance that manages the operation.
 boolean isReading()
           
protected  void reachedEOF()
          Stop the reading and void out any exceptions.
protected  void registerException(java.io.IOException ioe)
          Post an exception, and stop the reading.
 void setCloseInputOnStop(boolean on)
          By setting this to true the runner will close the InputStream once a Stop signal has been encountered.
 void setCloseOutputOnStop(boolean on)
          By setting this to true the runner will close the OutputStream once a Stop signal has been encountered.
 void start()
          Starts the stream reading.
 void stop()
          Stops the thread from reading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOThreadRunner

public IOThreadRunner(java.io.InputStream is,
                      java.io.OutputStream os)
Create a new ThreadRunner, re-routing is data into the os stream.


IOThreadRunner

public IOThreadRunner(LoopThread lt,
                      java.io.InputStream is,
                      java.io.OutputStream os)
Create a new ThreadRunner, re-routing is data into the os stream, but uses the initialization of the given LoopThread. Note that lt must not be a running thread.

Method Detail

getException

public java.io.IOException getException()
Retrieves the most recent exception that occured, if any. If no exception happened, then it returns null.


setCloseInputOnStop

public void setCloseInputOnStop(boolean on)
By setting this to true the runner will close the InputStream once a Stop signal has been encountered.


setCloseOutputOnStop

public void setCloseOutputOnStop(boolean on)
By setting this to true the runner will close the OutputStream once a Stop signal has been encountered.


getThread

public LoopThread getThread()
Retrieves the LoopThread instance that manages the operation. You can use this instance for setting up the thread (such as setting priority and daemon status).


getOutputStream

public java.io.OutputStream getOutputStream()
Retrieves the output stream that the input is redirected to.


isReading

public boolean isReading()
Returns:
true if the thread is alive and reading the stream, or false if it is not reading.

start

public void start()
Starts the stream reading.


stop

public void stop()
          throws java.io.IOException
Stops the thread from reading.

Throws:
java.io.IOException

registerException

protected void registerException(java.io.IOException ioe)
Post an exception, and stop the reading.


reachedEOF

protected void reachedEOF()
Stop the reading and void out any exceptions.



Copyright © 2001-2003 by The GroboUtils Project