|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.presentation.stream.DataReader
public abstract class DataReader
Data reader abstraction layer.
Provides the common API and general functional for an any incoming data reader.
Nested Class Summary | |
---|---|
class |
DataReader.Locator
The location representation class. |
Field Summary | |
---|---|
protected int |
count
The index one greater than the index of the last valid byte in the buffer. |
protected boolean |
eof
|
protected DataReader.Locator |
locator
The location representation instance. |
protected int |
pos
The current position in the buffer. |
Constructor Summary | |
---|---|
DataReader()
|
Method Summary | |
---|---|
int |
available()
Returns the number of bytes that can be read from this input stream without blocking. |
abstract void |
close()
Closes this reader and releases any system resources associated with it. |
protected abstract void |
compact(int from,
int requested)
Compacts the data in the internal buffer. |
protected void |
ensureOpen(int length)
Check to make sure that this reader has enough data to read the length bytes. |
boolean |
eof()
|
protected abstract int |
fill(int requested)
Fills out the internal buffer by next data portion. |
InputStream |
getDataStream()
Returns the underlied incoming data stream. |
DataReader.Locator |
getLocator()
Current locator getter. |
int |
getLookAhead()
Returns the look ahead limit. |
int |
getLookBehind()
Returns the look behind limit. |
DataReader.Locator |
mark()
Returns the snapshot of current location within data stream that can be used on rollback. |
void |
rollback(DataReader.Locator locator)
Rollback on specified location. |
void |
setLookAhead(int lookAhead)
Sets the look ahead limit. |
void |
setLookBehind(int lookBehind)
Sets the look behind limit. |
int |
skip(int n)
See the general contract of the skip method of
InputStream . |
protected void |
updateLocator(int skipped)
Updates the location with specified changes of position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int count
0
through
buffer.length
; elements buffer[0]
through
buffer[count-1]
contain buffered input data obtained from the
underlying input stream.
protected int pos
buffer
array.
This value is always in the range 0
through
count
. If it is less than count
, then
buffer[pos]
is the next byte to be supplied as input; if it is
equal to count
, then the next read
or
skip
operation will require more bytes to be read from the
contained input stream.
ByteAlignedBitDataReader.buffer
protected DataReader.Locator locator
protected boolean eof
Constructor Detail |
---|
public DataReader()
Method Detail |
---|
public final int getLookAhead()
public final int getLookBehind()
public final void setLookAhead(int lookAhead)
lookAhead
- the new look ahead limit.public final void setLookBehind(int lookBehind)
lookBehind
- the new look behind limit.public final DataReader.Locator getLocator()
locator
instance. Returnad
instance shouldn't be changed.
public int skip(int n) throws IOException
skip
method of
InputStream
.
n
- the number of bytes to be skipped.
IOException
- if an I/O error occurs.public final DataReader.Locator mark()
rollback(biz.c24.io.api.presentation.stream.DataReader.Locator)
public void rollback(DataReader.Locator locator)
limit
the exception is throwned.
locator
- the location of point within data stream to where location should be rolled back.
IllegalStateException
- If location is out from allowed range.mark()
public int available()
available
method of BufferedInputStream
returns the sum of the the number of bytes remaining to be read in the
buffer (count - pos
) and the result of calling the
available
method of the underlying input stream.
FilterInputStream.in
public InputStream getDataStream()
exception
.
incoming data stream
.
UnsupportedOperationException
- If implementation doesn't provided that ability.public abstract void close() throws IOException
IOException
- if an I/O error occurs.protected abstract int fill(int requested) throws IOException
requested
- the number of byte that were requested.
IOException
- If unexpected I/O error happends.protected abstract void compact(int from, int requested) throws IOException
limit
values.
from
- The pointer in buffer up to which data may be marked as invalidated.requested
- the number of bytes that should stay in buffer in any way.
IOException
- If unexpected I/O error happends.public final boolean eof()
protected final void ensureOpen(int length) throws IOException
length
- the length of data that should be available.
IOException
- If underlied stream is corrupted.protected void updateLocator(int skipped)
skipped
- the number of bytes on which location has been moved.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |