ewe.io
Class PartialOutputStream

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

public class PartialOutputStream
extends StreamAdapter

This class is used to create a "sub-stream" of data int another Stream. The partial stream can limit the amount of data which can be written to the original Stream. Note the following: 1. Calling close() on a PartialOutputStream does not close the original stream. 2. Setting a limit of -1 will not impose any limit on the number of bytes which can be read. 3. Input begins at the current point in the source input stream.


Field Summary
 
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
PartialOutputStream(BasicStream output)
          Creates a new PartialOutputStream with no limit.
PartialOutputStream(BasicStream output, int limit)
          Creates a new PartialOutputStream with the specified limit.
PartialOutputStream(RandomAccessStream raf, int start, int limit)
           
 
Method Summary
 boolean closeStream()
          This will not close the underlying stream.
 boolean isOpen()
          Returns if the stream is open or not.
 int nonBlockingRead(byte[] buff, int start, int length)
          This calls the nonBlockingRead() of the client BasicStream.
 int nonBlockingWrite(byte[] buff, int offset, int count)
          This calls the nonBlockingWrite() of the client BasicStream.
 boolean pushback(byte[] bytes, int start, int count)
          Push back some bytes into the input stream.
 
Methods inherited from class ewe.io.StreamAdapter
flushStream, pauseUntilReady
 
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
 

Constructor Detail

PartialOutputStream

public PartialOutputStream(BasicStream output)
Creates a new PartialOutputStream with no limit.


PartialOutputStream

public PartialOutputStream(BasicStream output,
                           int limit)
Creates a new PartialOutputStream with the specified limit. If the limit is -1, then there will be no limit imposed


PartialOutputStream

public PartialOutputStream(RandomAccessStream raf,
                           int start,
                           int limit)
Method Detail

nonBlockingRead

public int nonBlockingRead(byte[] buff,
                           int start,
                           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

nonBlockingWrite

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

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

closeStream

public boolean closeStream()
                    throws IOException
This will not close the underlying stream.

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

isOpen

public boolean isOpen()
Description copied from interface: BasicStream
Returns if the stream is open or not.

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

pushback

public boolean pushback(byte[] bytes,
                        int start,
                        int count)
Description copied from class: StreamAdapter
Push back some bytes into the input stream. There is no limit on the number of bytes which can be pushed back. This can be called multiple times.

Specified by:
pushback in interface BufferedStream
Overrides:
pushback in class StreamAdapter