|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream PIRL.Utilities.ByteBuffer_InputStream
public class ByteBuffer_InputStream
A ByteBuffer_InputStream presents a ByteBuffer as an InputStream.
This class is thread safe: Methods that might modify the backing ByteBuffer are synchronized on the ByteBuffer.
ByteBuffer
,
InputStream
Field Summary | |
---|---|
static String |
ID
Class identification name with source code version and date. |
Constructor Summary | |
---|---|
ByteBuffer_InputStream(ByteBuffer source)
Construct a ByteBuffer_InputStream on a ByteBuffer. |
Method Summary | |
---|---|
int |
available()
Get the number of bytes remaining in the source. |
void |
mark(int read_limit)
Sets a mark at the current input position. |
boolean |
markSupported()
Test if stream mark and reset are
supported. |
int |
read()
Get the next datum from the source. |
int |
read(byte[] byte_array)
Get some number of bytes from the source and store them into a byte array. |
int |
read(byte[] byte_array,
int offset,
int length)
Get some number of bytes from the source and store them into a byte array. |
void |
reset()
Reset the source position to the most recent
mark position. |
long |
skip(long amount)
Skip over some number of input bytes. |
ByteBuffer |
Source()
Get the ByteBuffer backing this ByteBuffer_InputStream. |
Methods inherited from class java.io.InputStream |
---|
close |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID
Constructor Detail |
---|
public ByteBuffer_InputStream(ByteBuffer source)
source
- The ByteBuffer to be used as the source of input data.Method Detail |
---|
public ByteBuffer Source()
public int available()
available
in class InputStream
source
.
This is the difference between the buffer's current input
position
and the input limit
. Note that the limit may be less than the
buffer capacity
.public void mark(int read_limit)
The operation is synchronized on the source buffer.
mark
in class InputStream
read_limit
- Ignored: The read limit is always the
source
limit.public boolean markSupported()
mark
and reset
are
supported.
markSupported
in class InputStream
public int read()
The operation is synchronized on the source buffer.
read
in class InputStream
source
byte (0-255) at
the current buffer position, or -1 if the source
position is at its limit
.public int read(byte[] byte_array)
This method simply returns
read (byte_array, 0, byte_array.length)
.
read
in class InputStream
byte_array
- A byte[] array where the source data is to be
stored.
source
position is at its limit
.
NullPointerException
- If the byte array is null.read(byte[], int, int)
public int read(byte[] byte_array, int offset, int length)
If the length to read is less than or equal to zero, zero is
returned. Otherwise the effective length is the lesser of the
length and the amount of data remaining
in the source
buffer.
The operation is synchronized on the source buffer.
read
in class InputStream
byte_array
- A byte[] array where the source data is to be
stored.offset
- The index of the array where the first byte will be
stored.length
- The maximum number of bytes to transfer from the
source
to the array.
source
position is at its limit
.
NullPointerException
- If the byte array is null.
IndexOutOfBoundsException
- If the offset is negative or
the offset plus the effective length is greater than the
remaining space in the array.public void reset() throws IOException
source
position to the most recent
mark
position.
The operation is synchronized on the source buffer.
reset
in class InputStream
IOException
- If no mark has been set.public long skip(long amount)
The source
input position is moved to its
current position plus the lesser of the amount specified or
the amount available data remaining
in the buffer.
The operation is synchronized on the source buffer.
skip
in class InputStream
amount
- The amount of data to skip.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |