mediautil.gen.directio
Interface IterativeReader

All Known Implementing Classes:
BasicJpeg, LLJTran

public interface IterativeReader

Interface specifying read from a stream in small chunks. This interface specifies an Object to read from an InputStream in small chunks. An IterativeReader class can support the directio package's features of Sharing an InputStream with another reader and providing an OutputStream to save directly for the IterativeReader to read.

See Also:
mediautil.gen.directio, SplitInputStream, OutStreamToIterativeReader

Field Summary
static int CONTINUE
          Constant which specifies that the IterativeReader/IterativeWriter is not done with nextRead/nextWrite.
static int STOP
          Constant which specifies that the IterativeReader/IterativeWriter is done with nextRead/nextWrite.
 
Method Summary
 int nextRead(int numBytes)
          Specifies that numBytes bytes are to be read.
 

Field Detail

CONTINUE

static final int CONTINUE
Constant which specifies that the IterativeReader/IterativeWriter is not done with nextRead/nextWrite.

See Also:
Constant Field Values

STOP

static final int STOP
Constant which specifies that the IterativeReader/IterativeWriter is done with nextRead/nextWrite. This means that the reading/writing is complete and further calls of nextRead/nextWrite are not expected.

See Also:
Constant Field Values
Method Detail

nextRead

int nextRead(int numBytes)
             throws IOException
Specifies that numBytes bytes are to be read. The InputStream to read from should be stored in the implementing class.

Parameters:
numBytes - Number of bytes to read. This is only indicative. The implementor may read more or less. Reading too less impacts performance due to repeated nextRead calls. Reading too much more than numBytes leads to performance impact due to buffer reallocation in case of SplitInputStream and an IOException due to Empty Buffer in an OutStreamToIterativeReader.

The InputStream returned for use by an IterativeReader by directio's classes implement ByteCounter which can help in keeping track of the number of bytes read or remaining during a nextRead call.

Returns:
CONTINUE to indicate that there is more to be read and STOP to indicate that the IterativeReader is done with reading.
Throws:
IOException - In case of an error during read. Note that data errors can also be handled by returning STOP and storing the error instead of throwing an Exception. This may be desirable for a SplitInputStream since the main Read can continue unhindered by the SubStream's error.