com.cometway.util
Class InputStreamReaderKMethod

java.lang.Object
  extended by com.cometway.util.KMethod
      extended by com.cometway.util.InputStreamReaderKMethod
All Implemented Interfaces:
java.lang.Runnable

public class InputStreamReaderKMethod
extends KMethod
implements java.lang.Runnable

This method extends com.cometway.util.KMethod and implements the Runnable interface, which allows this KMethod to be executed by a PooledThread from a ThreadPool or another Thread. When executed, the InputStream given to this class is read from until either an End Of Transmission character is reached or the Thread is stopped.


Field Summary
 boolean changeCRtoLF
          Set this flag to true if you want to be Carriage Returns replaced by Line Feeds.
 boolean changeLFtoCR
          Set this flag to true if you want Line Feeds to be replaced by Carriage Returns.
 java.lang.Thread currentThread
          This is set to the Thread that is executing this KMethod upon execution.
 java.lang.Object finishedReadNotify
          Set this to the Object to notify() when the read has completed.
 boolean isRunning
          This flag is set to TRUE when this KMethod is being executed.
 int readCharLimit
          Set this to a value greater than zero and only this many characters will be read.
 
Fields inherited from class com.cometway.util.KMethod
args, debugName, method, obj, print_errors, run, verbose
 
Constructor Summary
InputStreamReaderKMethod(java.io.InputStream inputStream)
           
InputStreamReaderKMethod(java.io.InputStream inputStream, int endOfTransmissionChar)
           
InputStreamReaderKMethod(java.io.InputStream inputStream, java.lang.StringBuffer readBuffer)
           
InputStreamReaderKMethod(java.io.InputStream inputStream, java.lang.StringBuffer readBuffer, int endOfTransmissionChar)
           
 
Method Summary
 void execute()
          Overrides KMethod.execute()
 java.lang.StringBuffer getBuffer()
          This method returns the StringBuffer that the InputStream is read into.
 void run()
          This starts reading the InputStream.
 void stopReadThread()
          This method stops the Thread that is executing this KMethod.
 
Methods inherited from class com.cometway.util.KMethod
error, error, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

finishedReadNotify

public java.lang.Object finishedReadNotify
Set this to the Object to notify() when the read has completed.


currentThread

public java.lang.Thread currentThread
This is set to the Thread that is executing this KMethod upon execution.


isRunning

public boolean isRunning
This flag is set to TRUE when this KMethod is being executed.


changeLFtoCR

public boolean changeLFtoCR
Set this flag to true if you want Line Feeds to be replaced by Carriage Returns.


changeCRtoLF

public boolean changeCRtoLF
Set this flag to true if you want to be Carriage Returns replaced by Line Feeds.


readCharLimit

public int readCharLimit
Set this to a value greater than zero and only this many characters will be read.

Constructor Detail

InputStreamReaderKMethod

public InputStreamReaderKMethod(java.io.InputStream inputStream)

InputStreamReaderKMethod

public InputStreamReaderKMethod(java.io.InputStream inputStream,
                                java.lang.StringBuffer readBuffer)

InputStreamReaderKMethod

public InputStreamReaderKMethod(java.io.InputStream inputStream,
                                int endOfTransmissionChar)

InputStreamReaderKMethod

public InputStreamReaderKMethod(java.io.InputStream inputStream,
                                java.lang.StringBuffer readBuffer,
                                int endOfTransmissionChar)
Method Detail

execute

public void execute()
Overrides KMethod.execute()

Overrides:
execute in class KMethod

run

public void run()
This starts reading the InputStream. This method also sets the 'isRunning' and the 'currentThread' fields.

Specified by:
run in interface java.lang.Runnable

getBuffer

public java.lang.StringBuffer getBuffer()
This method returns the StringBuffer that the InputStream is read into.


stopReadThread

public void stopReadThread()
This method stops the Thread that is executing this KMethod. If the Thread is a PooledThread, it should be released from its ThreadPool before calling this method. This method calls Thread.stop() on the Thread executing this KMethod.