|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.Buffer
java.nio.ByteBuffer
java.nio.BaseByteBuffer
java.nio.HeapByteBuffer
java.nio.ReadOnlyHeapByteBuffer
final class ReadOnlyHeapByteBuffer
HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers.
ReadOnlyHeapByteBuffer extends HeapByteBuffer with all the write methods throwing read only exception.
This class is marked final for runtime performance.
| Field Summary |
|---|
| Fields inherited from class java.nio.HeapByteBuffer |
|---|
backingArray, offset |
| Fields inherited from class java.nio.ByteBuffer |
|---|
order |
| Fields inherited from class java.nio.Buffer |
|---|
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK |
| Constructor Summary | |
|---|---|
ReadOnlyHeapByteBuffer(byte[] backingArray,
int capacity,
int arrayOffset)
|
|
| Method Summary | |
|---|---|
ByteBuffer |
asReadOnlyBuffer()
Returns a readonly buffer that shares content with this buffer. |
ByteBuffer |
compact()
Compacts this byte buffer. |
(package private) static ReadOnlyHeapByteBuffer |
copy(HeapByteBuffer other,
int markOfOther)
|
ByteBuffer |
duplicate()
Returns a duplicated buffer that shares content with this buffer. |
boolean |
isReadOnly()
Returns whether this buffer is readonly or not. |
protected byte[] |
protectedArray()
Child class implements this method to realize array(). |
protected int |
protectedArrayOffset()
Child class implements this method to realize arrayOffset(). |
protected boolean |
protectedHasArray()
Child class implements this method to realize hasArray(). |
ByteBuffer |
put(byte b)
Writes the given byte to the current position and increase the position by 1. |
ByteBuffer |
put(byte[] src,
int off,
int len)
Writes bytes in the given byte array, starting from the
specified offset, to the current position and increase the position by
the number of bytes written. |
ByteBuffer |
put(ByteBuffer buf)
Writes all the remaining bytes of the src
byte buffer to this buffer's current position, and increase both buffers'
position by the number of bytes copied. |
ByteBuffer |
put(int index,
byte b)
Write a byte to the specified index of this buffer and the position is not changed. |
ByteBuffer |
putDouble(double value)
Writes the given double to the current position and increase the position by 8. |
ByteBuffer |
putDouble(int index,
double value)
Write a double to the specified index of this buffer. |
ByteBuffer |
putFloat(float value)
Writes the given float to the current position and increase the position by 4. |
ByteBuffer |
putFloat(int index,
float value)
Write a float to the specified index of this buffer. |
ByteBuffer |
putInt(int value)
Writes the given int to the current position and increase the position by 4. |
ByteBuffer |
putInt(int index,
int value)
Write a int to the specified index of this buffer. |
ByteBuffer |
putLong(int index,
long value)
Write a long to the specified index of this buffer. |
ByteBuffer |
putLong(long value)
Writes the given long to the current position and increase the position by 8. |
ByteBuffer |
putShort(int index,
short value)
Write a short to the specified index of this buffer. |
ByteBuffer |
putShort(short value)
Writes the given short to the current position and increase the position by 2. |
ByteBuffer |
slice()
Returns a sliced buffer that shares content with this buffer. |
| Methods inherited from class java.nio.HeapByteBuffer |
|---|
get, get, get, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, isDirect, loadInt, loadLong, loadShort, store, store, store |
| Methods inherited from class java.nio.BaseByteBuffer |
|---|
asCharBuffer, asDoubleBuffer, asFloatBuffer, asIntBuffer, asLongBuffer, asShortBuffer, getChar, getChar, putChar, putChar |
| Methods inherited from class java.nio.ByteBuffer |
|---|
_array, _arrayOffset, allocate, allocateDirect, array, arrayOffset, compareTo, equals, get, hasArray, hashCode, order, order, orderImpl, put, toString, wrap, wrap |
| Methods inherited from class java.nio.Buffer |
|---|
capacity, clear, flip, hasRemaining, limit, limit, mark, position, position, remaining, reset, rewind |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
ReadOnlyHeapByteBuffer(byte[] backingArray,
int capacity,
int arrayOffset)
| Method Detail |
|---|
static ReadOnlyHeapByteBuffer copy(HeapByteBuffer other,
int markOfOther)
public ByteBuffer asReadOnlyBuffer()
ByteBufferThe returned buffer is guaranteed to be a new instance, even this buffer is readonly itself. The new buffer's position, limit, capacity and mark are the same as this buffer.
The new buffer shares content with this buffer, which means this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.
asReadOnlyBuffer in class ByteBufferpublic ByteBuffer compact()
ByteBuffer
The remaining bytes will be moved to the head of the
buffer, staring from position zero. Then the position is set to
remaining(); the limit is set to capacity; the mark is
cleared.
compact in class ByteBufferpublic ByteBuffer duplicate()
ByteBufferThe duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's readonly property and byte order are same as this buffer too.
The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
duplicate in class ByteBufferpublic boolean isReadOnly()
Buffer
isReadOnly in class Bufferprotected byte[] protectedArray()
ByteBufferarray().
protectedArray in class ByteBufferarray()protected int protectedArrayOffset()
ByteBufferarrayOffset().
protectedArrayOffset in class ByteBufferarrayOffset()protected boolean protectedHasArray()
ByteBufferhasArray().
protectedHasArray in class ByteBufferhasArray()public ByteBuffer put(byte b)
ByteBuffer
put in class ByteBufferb - The byte to write
public ByteBuffer put(int index,
byte b)
ByteBuffer
put in class ByteBufferindex - The index, must be no less than zero and less than the limitb - The byte to write
public ByteBuffer put(byte[] src,
int off,
int len)
ByteBufferbytes in the given byte array, starting from the
specified offset, to the current position and increase the position by
the number of bytes written.
put in class ByteBuffersrc - The source byte arrayoff - The offset of byte array, must be no less than zero and no
greater than src.lengthlen - The number of bytes to write, must be no less
than zero and no greater than src.length - off
public ByteBuffer putDouble(double value)
ByteBufferThe double is converted to bytes using the current byte order.
putDouble in class ByteBuffervalue - The double to write
public ByteBuffer putDouble(int index,
double value)
ByteBufferThe double is converted to bytes using the current byte order. The position is not changed.
putDouble in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 8value - The double to write
public ByteBuffer putFloat(float value)
ByteBufferThe float is converted to bytes using the current byte order.
putFloat in class ByteBuffervalue - The float to write
public ByteBuffer putFloat(int index,
float value)
ByteBufferThe float is converted to bytes using the current byte order. The position is not changed.
putFloat in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 4value - The float to write
public ByteBuffer putInt(int value)
ByteBufferThe int is converted to bytes using the current byte order.
putInt in class ByteBuffervalue - The int to write
public ByteBuffer putInt(int index,
int value)
ByteBufferThe int is converted to bytes using the current byte order. The position is not changed.
putInt in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 4value - The int to write
public ByteBuffer putLong(int index,
long value)
ByteBufferThe long is converted to bytes using the current byte order. The position is not changed.
putLong in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 8value - The long to write
public ByteBuffer putLong(long value)
ByteBufferThe long is converted to bytes using the current byte order.
putLong in class ByteBuffervalue - The long to write
public ByteBuffer putShort(int index,
short value)
ByteBufferThe short is converted to bytes using the current byte order. The position is not changed.
putShort in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 2value - The short to write
public ByteBuffer putShort(short value)
ByteBufferThe short is converted to bytes using the current byte order.
putShort in class ByteBuffervalue - The short to write
public ByteBuffer put(ByteBuffer buf)
ByteBufferbytes of the src
byte buffer to this buffer's current position, and increase both buffers'
position by the number of bytes copied.
put in class ByteBufferbuf - The source byte buffer
public ByteBuffer slice()
ByteBuffer
The sliced buffer's capacity will be this buffer's
remaining(), and its zero position will correspond to
this buffer's current position. The new buffer's position will be
0, limit will be its capacity, and its mark is unset. The new buffer's
readonly property and byte order are same as this buffer.
The new buffer shares content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
slice in class ByteBuffer
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||