|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ReadBuffer
The ReadBuffer interface represents an in-memory block of binary data, such as that represented by a byte[], a Binary object, or an NIO buffer.
Nested Class Summary | |
---|---|
static interface |
ReadBuffer.BufferInput The BufferInput interface represents a DataInputStream on top of a ReadBuffer. |
Method Summary | |
---|---|
byte |
byteAt(int of) Returns the byte at the specified offset. |
java.lang.Object |
clone() Create a clone of this ReadBuffer object. |
void |
copyBytes(int ofBegin, int ofEnd, byte[] abDest, int ofDest) Copies bytes from this ReadBuffer into the destination byte array. |
boolean |
equals(java.lang.Object o) Compare two ReadBuffer objects for equality. |
ReadBuffer.BufferInput |
getBufferInput() Get a BufferInput object to read data from this buffer. |
ReadBuffer |
getReadBuffer(int of, int cb) Obtain a ReadBuffer for a portion of this ReadBuffer. |
int |
length() Determine the length of the buffer. |
ByteSequence |
subSequence(int ofStart, int ofEnd) Returns a new ByteSequence that is a subsequence of this sequence. |
Binary |
toBinary() Return a new Binary object that holds the complete contents of this ReadBuffer. |
Binary |
toBinary(int of, int cb) Return a Binary object that holds the specified portion of this ReadBuffer. |
byte[] |
toByteArray() Get the contents of the ReadBuffer as a byte array. |
byte[] |
toByteArray(int of, int cb) Get a portion of the contents of the ReadBuffer as a byte array. |
java.nio.ByteBuffer |
toByteBuffer() Return a read-only ByteBuffer view of this ReadBuffer. |
java.nio.ByteBuffer |
toByteBuffer(int of, int cb) Return a read-only ByteBuffer view of the specified portion of this ReadBuffer. |
void |
writeTo(java.nio.ByteBuffer buf) Write the contents of the Binary object to a ByteBuffer. |
void |
writeTo(java.nio.ByteBuffer buf, int of, int cb) Write the contents of the Binary object to a ByteBuffer. |
void |
writeTo(java.io.DataOutput out) Write the contents of this ReadBuffer to a DataOutput. |
void |
writeTo(java.io.DataOutput out, int of, int cb) Write the contents of this ReadBuffer to a DataOutput. |
void |
writeTo(java.io.OutputStream out) Write the contents of this ReadBuffer to an OutputStream. |
void |
writeTo(java.io.OutputStream out, int of, int cb) Write the contents of the ReadBuffer to an OutputStream. |
Method Detail |
---|
int length()
length
in interface ByteSequence
byte byteAt(int of)
0
to length() - 1
. The first byte of the sequence is at offset 0
, the next at offset 1
, and so on, as for array indexing.byteAt
in interface ByteSequence
of
- the offset (index) of the bytejava.lang.IndexOutOfBoundsException
- if the of
argument is negative or not less than the length of this ReadBuffervoid copyBytes(int ofBegin, int ofEnd, byte[] abDest, int ofDest)
The first byte to be copied is at offset ofBegin
; the last byte to be copied is at offset ofEnd-1
(thus the total number of bytes to be copied is ofEnd - ofBegin
). The bytes are copied into the sub-array of abDest
starting at offset ofDest
and ending at index:
ofDest + (ofEnd - ofBegin) - 1
This method is the ReadBuffer equivalent of String.getChars(int, int, char[], int)
. It allows the caller to extract a chunk of bytes into the caller's own array.
ofBegin
- offset of the first byte in the ReadBuffer to copyofEnd
- offset after the last byte in the ReadBuffer to copyabDest
- the destination byte arrayofDest
- the offset in the destination byte array to copy the first byte tojava.lang.IndexOutOfBoundsException
- Thrown if any of the following is true:
ofBegin
is negative;ofBegin
is greater than ofEnd
ofEnd
is greater than the length of this ReadBuffer;ofDest
is negativeofDest + (ofEnd - ofBegin)
is larger than abDest.length
java.lang.NullPointerException
- if abDest
is null
ReadBuffer.BufferInput getBufferInput()
ReadBuffer getReadBuffer(int of, int cb)
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting ReadBufferjava.lang.IndexOutOfBoundsException
- if of
or cb
is negative, or of + cb
is larger than the length of this ReadBuffer
objectvoid writeTo(java.io.OutputStream out) throws java.io.IOException
out
- an OutputStream to write tojava.io.IOException
- if an I/O exception occursvoid writeTo(java.io.OutputStream out, int of, int cb) throws java.io.IOException
out
- an OutputStream to write toof
- the beginning index, inclusivecb
- the number of bytes to write to an OutputStreamjava.io.IOException
- if an I/O exception occursvoid writeTo(java.io.DataOutput out) throws java.io.IOException
out
- a DataOutput to write tojava.io.IOException
- if an I/O exception occursvoid writeTo(java.io.DataOutput out, int of, int cb) throws java.io.IOException
out
- a DataOutput to write toof
- the beginning index, inclusivecb
- the number of bytes to write to a DataOutputjava.io.IOException
- if an I/O exception occursvoid writeTo(java.nio.ByteBuffer buf)
buf
- a ByteBuffer to write tovoid writeTo(java.nio.ByteBuffer buf, int of, int cb) throws java.io.IOException
buf
- an ByteBuffer to write toof
- the beginning index, inclusivecb
- the number of bytes to write to a ByteBufferjava.io.IOException
- if an I/O exception occursbyte[] toByteArray()
This is the equivalent of toByteArray(0, length())
.
byte[] toByteArray(int of, int cb)
This method is an equivalent of getReadBuffer(of, cb).toByteArray()
.
of
- the beginning index, inclusivecb
- the number of bytes to include in the resulting byte[]java.lang.IndexOutOfBoundsException
- if of
or cb
is negative, or of + cb
is larger than the length of this ReadBuffer
objectBinary toBinary()
This is the equivalent of toBinary(0, length())
.
toBinary
in interface ByteSequence
Binary toBinary(int of, int cb)
This method is an equivalent of getReadBuffer(of, cb).toBinary()
.
of
- the beginning index, inclusivecb
- the number of bytes to include in the Binary objectjava.lang.IndexOutOfBoundsException
- if of
or cb
is negative, or of + cb
is larger than the length of this ReadBuffer
objectjava.nio.ByteBuffer toByteBuffer()
java.nio.ByteBuffer toByteBuffer(int of, int cb)
This method is an equivalent of getReadBuffer(of, cb).toByteBuffer()
.
of
- the beginning index, inclusivecb
- the number of bytes to include in the ByteBuffer objectjava.lang.IndexOutOfBoundsException
- if of
or cb
is negative, or of + cb
is larger than the length of this ReadBuffer
objectByteSequence subSequence(int ofStart, int ofEnd)
ByteSequence
that is a subsequence of this sequence. The subsequence starts with the byte
value at the specified index and ends with the byte
value at index ofEnd - 1. The length (in byte
s) of the returned sequence is ofEnd - ofStart, so if ofStart == ofEnd then an empty sequence is returned.subSequence
in interface ByteSequence
ofStart
- the start index, inclusiveofEnd
- the end index, exclusiveboolean equals(java.lang.Object o)
o
- a ReadBuffer objectjava.lang.Object clone()
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |