|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.util.io.CountingDataSource
public class CountingDataSource
This DataSource
counts how many bytes that are read or skipped past
from a proxied data source.
Constructor Summary | |
---|---|
CountingDataSource(DataSource proxied)
|
Method Summary | |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read from this data source without blocking by the next invocation of a method for this data source. |
void |
close()
Close the source and free all resources associated with it. |
long |
getCount()
Get the number of bytes read or skipped past in this data source. |
int |
read()
Read a byte of data from the source. |
int |
read(byte[] barr)
Read up to b.length bytes of data from the source into the array. |
int |
read(byte[] barr,
int off,
int len)
Read up to len bytes of data from the source into the array. |
long |
skipBytes(long n)
Attempt to skip over n bytes in the source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CountingDataSource(DataSource proxied)
Method Detail |
---|
public int available() throws IllegalStateException, WrappedIOException
DataSource
available
in interface DataSource
IllegalStateException
- If the source is closed.
WrappedIOException
- On I/O errors.InputStream.available()
public int read() throws IllegalStateException, WrappedIOException
DataSource
0x00-0x0ff
).
read
in interface DataSource
-1
if the end of the source has
been reached.
IllegalStateException
- If the source is closed.
WrappedIOException
- On I/O errors.public int read(byte[] barr) throws IllegalStateException, WrappedIOException
DataSource
b.length
bytes of data from the source into the array.
read
in interface DataSource
barr
- The byte array into which data is read.
-1
if
no data could be read because the the end of the source was reached
before the read started.
IllegalStateException
- If the source is closed.
WrappedIOException
- On I/O errors.public int read(byte[] barr, int off, int len) throws IllegalStateException, WrappedIOException
DataSource
len
bytes of data from the source into the array.
read
in interface DataSource
barr
- The byte array into which data is read.off
- The start offset in the array b
at which data is
written.len
- The maximum number of bytes to read.
-1
if
no data could be read because the end of the source was reached before
the read started.
IllegalStateException
- If the source is closed.
WrappedIOException
- On I/O errors.public long skipBytes(long n) throws IllegalStateException
DataSource
n
bytes in the source. If n
is
negative, no bytes are skipped.
The pointer in the source cannot be moved beyond EOF using this method
(unlike RandomAccess.seek(long)
).
skipBytes
in interface DataSource
n
- The number of bytes to increment the source pointer with.
IllegalStateException
- If the source is closed.RandomAccess.seek(long)
public void close() throws WrappedIOException
DataSource
close
in interface DataSource
WrappedIOException
- On I/O errors.public long getCount()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |