ewe.io
Class DataProcessorStream

java.lang.Object
  extended byewe.util.Errorable
      extended byewe.io.BasicStreamObject
          extended byewe.io.StreamObject
              extended byewe.io.StreamAdapter
                  extended byewe.io.DataProcessorStream
All Implemented Interfaces:
BasicStream, BufferedStream, OverridesClose, Stream, Streamable, StreamCanPause

public class DataProcessorStream
extends StreamAdapter
implements OverridesClose

This is a ONE-WAY stream. Which way is up to you - depending on whether you write data to it or read data from it. You MUST ensure that you flush (for output) or close the stream after you have finished sending/receiving all the data to ensure that data processing is fully complete. This does NOT call closeProcess on the DataProcessor.


Field Summary
protected  int blockSize
           
 byte padByte
          In the case of block sizes greater than 1, it may be necessary to pad the final set of data before processing.
 DataProcessor processor
           
 
Fields inherited from class ewe.io.StreamAdapter
in, out, stream
 
Fields inherited from class ewe.io.StreamObject
napIterations, napTime, READWRITE_CLOSED, READWRITE_ERROR, READWRITE_WOULDBLOCK
 
Fields inherited from class ewe.io.BasicStreamObject
closed
 
Fields inherited from class ewe.util.Errorable
error
 
Fields inherited from interface ewe.io.StreamCanPause
PAUSE_UNTIL_CAN_READ, PAUSE_UNTIL_CAN_WRITE, PAUSE_UNTIL_CLOSED, PAUSE_UNTIL_FLUSHED
 
Constructor Summary
DataProcessorStream(DataProcessor processor, BasicStream stream)
           
DataProcessorStream(DataProcessor processor, BasicStream stream, int bufferSize)
           
 
Method Summary
protected  int cantProcess(Exception e)
           
protected  int cantWrite()
           
protected  boolean clearOutput()
           
 boolean closeStream()
          This is non-blocking.
protected  boolean finalWrite()
           
 int nonBlockingRead(byte[] data, int offset, int length)
          This calls the nonBlockingRead() of the client BasicStream.
 int nonBlockingWrite(byte[] data, int offset, int length)
          This calls the nonBlockingWrite() of the client BasicStream.
protected  int writeSomeOutput()
           
 
Methods inherited from class ewe.io.StreamAdapter
flushStream, isOpen, pauseUntilReady, pushback
 
Methods inherited from class ewe.io.StreamObject
close, doRead, doWrite, flush, nap, nap, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes
 
Methods inherited from class ewe.io.BasicStreamObject
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write
 
Methods inherited from class ewe.util.Errorable
returnError, returnError, returnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 
Methods inherited from interface ewe.io.Stream
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes
 
Methods inherited from interface ewe.io.BasicStream
close
 

Field Detail

blockSize

protected int blockSize

padByte

public byte padByte
In the case of block sizes greater than 1, it may be necessary to pad the final set of data before processing. The padByte value is used to determine the byte value that will be used for this padding.


processor

public DataProcessor processor
Constructor Detail

DataProcessorStream

public DataProcessorStream(DataProcessor processor,
                           BasicStream stream)

DataProcessorStream

public DataProcessorStream(DataProcessor processor,
                           BasicStream stream,
                           int bufferSize)
Method Detail

cantWrite

protected int cantWrite()

cantProcess

protected int cantProcess(Exception e)

writeSomeOutput

protected int writeSomeOutput()

clearOutput

protected boolean clearOutput()

nonBlockingWrite

public int nonBlockingWrite(byte[] data,
                            int offset,
                            int length)
Description copied from class: StreamAdapter
This calls the nonBlockingWrite() of the client BasicStream.

Specified by:
nonBlockingWrite in interface BasicStream
Overrides:
nonBlockingWrite in class StreamAdapter

nonBlockingRead

public int nonBlockingRead(byte[] data,
                           int offset,
                           int length)
Description copied from class: StreamAdapter
This calls the nonBlockingRead() of the client BasicStream.

Specified by:
nonBlockingRead in interface BasicStream
Overrides:
nonBlockingRead in class StreamAdapter

finalWrite

protected boolean finalWrite()

closeStream

public boolean closeStream()
                    throws IOException
Description copied from interface: BasicStream
This is non-blocking. It returns true if the close completed, false if it did not, or throws an exception on error.

Specified by:
closeStream in interface BasicStream
Overrides:
closeStream in class StreamAdapter
Throws:
IOException