net.sf.japaki.io
Interface ReaderBuffer

All Superinterfaces:
Closeable
All Known Implementing Classes:
RingBuffer

public interface ReaderBuffer
extends Closeable

Implements a sort of a sliding window on a reader. In contrast to a standard Reader it counts the characters read and allows reading from a specified position. Because a typical implementation will use a buffer of a delimited size it is not guaranteed that data from an arbitrary position can be retrieved.


Method Summary
 void free(int pos)
          Frees the buffer before the specified position.
 int read(char[] cbuf, int off, int len, int pos)
          Retrieves a sequence of characters as described in read.
 
Methods inherited from interface java.io.Closeable
close
 

Method Detail

read

int read(char[] cbuf,
         int off,
         int len,
         int pos)
         throws IOException
Retrieves a sequence of characters as described in read.

Parameters:
cbuf - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
pos - Position, where to start reading in the stream
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
IOException - If the specified position is not covered by the underlying buffer or if an I/O error occurs

free

void free(int pos)
Frees the buffer before the specified position.

Parameters:
pos - All characters before this position may no longer be stored in the underlying buffer. Actual behaviour depends on the implementation.