|
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.DirectByteBuffer
abstract class DirectByteBuffer
DirectByteBuffer, ReadWriteDirectByteBuffer and ReadOnlyDirectByteBuffer compose the implementation of platform memory based byte buffers.
DirectByteBuffer implements all the shared readonly methods and is extended by the other two classes.
All methods are marked final for runtime performance.
| Nested Class Summary | |
|---|---|
(package private) static class |
DirectByteBuffer.SafeAddress
|
| Field Summary | |
|---|---|
protected int |
offset
|
protected DirectByteBuffer.SafeAddress |
safeAddress
|
| Fields inherited from class java.nio.ByteBuffer |
|---|
order |
| Fields inherited from class java.nio.Buffer |
|---|
_elementSizeShift, capacity, limit, mark, position, UNSET_MARK |
| Constructor Summary | |
|---|---|
DirectByteBuffer(DirectByteBuffer.SafeAddress address,
int capacity,
int offset)
|
|
DirectByteBuffer(int capacity)
|
|
| Method Summary | |
|---|---|
void |
addressValidityCheck()
|
void |
free()
Explicitly free the memory used by this direct byte buffer. |
byte |
get()
Returns the byte at the current position and increase the position by 1. |
ByteBuffer |
get(byte[] dest,
int off,
int len)
Reads bytes from the current position into the specified
byte array, starting from the specified offset, and increase the position
by the number of bytes read. |
byte |
get(int index)
Returns a byte at the specified index, and the position is not changed. |
org.apache.harmony.luni.platform.PlatformAddress |
getBaseAddress()
|
int |
getByteCapacity()
|
double |
getDouble()
Returns the double at the current position and increase the position by 8. |
double |
getDouble(int index)
Returns the double at the specified index. |
org.apache.harmony.luni.platform.PlatformAddress |
getEffectiveAddress()
Returns the platform address of the start of this buffer instance. |
float |
getFloat()
Returns the float at the current position and increase the position by 4. |
float |
getFloat(int index)
Returns the float at the specified index. |
int |
getInt()
Returns the int at the current position and increase the position by 4. |
int |
getInt(int index)
Returns the int at the specified index. |
long |
getLong()
Returns the long at the current position and increase the position by 8. |
long |
getLong(int index)
Returns the long at the specified index. |
short |
getShort()
Returns the short at the current position and increase the position by 2. |
short |
getShort(int index)
Returns the short at the specified index. |
boolean |
isAddressValid()
|
boolean |
isDirect()
Returns true if this buffer is direct. |
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(). |
| 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, asReadOnlyBuffer, compact, compareTo, duplicate, equals, get, hasArray, hashCode, order, order, orderImpl, put, put, put, put, put, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putShort, putShort, slice, toString, wrap, wrap |
| Methods inherited from class java.nio.Buffer |
|---|
capacity, clear, flip, hasRemaining, isReadOnly, limit, limit, mark, position, position, remaining, reset, rewind |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final DirectByteBuffer.SafeAddress safeAddress
protected final int offset
| Constructor Detail |
|---|
DirectByteBuffer(int capacity)
DirectByteBuffer(DirectByteBuffer.SafeAddress address,
int capacity,
int offset)
| Method Detail |
|---|
public final ByteBuffer get(byte[] dest,
int off,
int len)
ByteBufferbytes from the current position into the specified
byte array, starting from the specified offset, and increase the position
by the number of bytes read.
get in class ByteBufferdest - The target byte arrayoff - The offset of the byte array, must be no less than zero and no
greater than dest.lengthlen - The number of bytes to read, must be no less
than zero and no greater than dest.length - off
public final byte get()
ByteBuffer
get in class ByteBufferpublic final byte get(int index)
ByteBuffer
get in class ByteBufferindex - The index, must be no less than zero and less than limit
public final double getDouble()
ByteBufferThe 8 bytes start from the current position are composed into a double according to current byte order and returned. The position increases by 8.
getDouble in class ByteBufferpublic final double getDouble(int index)
ByteBufferThe 8 bytes start from the specified index are composed into a double according to current byte order and returned. The position is not changed.
getDouble in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 8
public final float getFloat()
ByteBufferThe 4 bytes start from the current position are composed into a float according to current byte order and returned. The position increases by 4.
getFloat in class ByteBufferpublic final float getFloat(int index)
ByteBufferThe 4 bytes start from the specified index are composed into a float according to current byte order and returned. The position is not changed.
getFloat in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 4
public final int getInt()
ByteBufferThe 4 bytes start from the current position are composed into a int according to current byte order and returned. The position increases by 4.
getInt in class ByteBufferpublic final int getInt(int index)
ByteBufferThe 4 bytes start from the specified index are composed into a int according to current byte order and returned. The position is not changed.
getInt in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 4
public final long getLong()
ByteBufferThe 8 bytes start from the current position are composed into a long according to current byte order and returned. The position increases by 8.
getLong in class ByteBufferpublic final long getLong(int index)
ByteBufferThe 8 bytes start from the specified index are composed into a long according to current byte order and returned. The position is not changed.
getLong in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 8
public final short getShort()
ByteBufferThe 2 bytes start from the current position are composed into a short according to current byte order and returned. The position increases by 2.
getShort in class ByteBufferpublic final short getShort(int index)
ByteBufferThe 2 bytes start from the specified index are composed into a short according to current byte order and returned. The position is not changed.
getShort in class ByteBufferindex - The index, must be no less than zero and equal or less than
limit - 2
public final boolean isDirect()
ByteBufferA byte buffer is direct, if it is based on a byte buffer and the byte buffer is direct.
isDirect in class ByteBufferpublic final boolean isAddressValid()
isAddressValid in interface org.apache.harmony.nio.internal.DirectBufferpublic final void addressValidityCheck()
addressValidityCheck in interface org.apache.harmony.nio.internal.DirectBufferpublic final org.apache.harmony.luni.platform.PlatformAddress getBaseAddress()
getBaseAddress in interface org.apache.harmony.nio.internal.DirectBufferpublic final org.apache.harmony.luni.platform.PlatformAddress getEffectiveAddress()
If you can guarantee that you want to free the underlying memory call the #free() method on this instance -- generally applications will rely on the garbage collector to autofree this memory.
getEffectiveAddress in interface org.apache.harmony.nio.internal.DirectBufferIllegalStateException - if this buffer address is known to have been freed
previously.public final void free()
IllegalStateException.
Note this is is possible that the memory is freed by code that reaches into the address and explicitly frees it 'beneith' us -- this is bad form.
free in interface org.apache.harmony.nio.internal.DirectBufferprotected final byte[] protectedArray()
ByteBufferarray().
protectedArray in class ByteBufferarray()protected final int protectedArrayOffset()
ByteBufferarrayOffset().
protectedArrayOffset in class ByteBufferarrayOffset()protected final boolean protectedHasArray()
ByteBufferhasArray().
protectedHasArray in class ByteBufferhasArray()public final int getByteCapacity()
getByteCapacity in interface org.apache.harmony.nio.internal.DirectBuffer
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||