Build 1.0_r1(from source)

java.nio
Class HeapByteBuffer

java.lang.Object
  extended by java.nio.Buffer
      extended by java.nio.ByteBuffer
          extended by java.nio.BaseByteBuffer
              extended by java.nio.HeapByteBuffer
All Implemented Interfaces:
Comparable<ByteBuffer>
Direct Known Subclasses:
ReadOnlyHeapByteBuffer, ReadWriteHeapByteBuffer

abstract class HeapByteBuffer
extends BaseByteBuffer

HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers.

HeapByteBuffer implements all the shared readonly methods and is extended by the other two classes.

All methods are marked final for runtime performance.


Field Summary
protected  byte[] backingArray
           
protected  int 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
HeapByteBuffer(byte[] backingArray)
           
HeapByteBuffer(byte[] backingArray, int capacity, int offset)
           
HeapByteBuffer(int capacity)
           
 
Method Summary
 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.
 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.
 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 isDirect()
          Returns true if this buffer is direct.
protected  int loadInt(int index)
           
protected  long loadLong(int index)
           
protected  short loadShort(int index)
           
protected  void store(int index, int value)
           
protected  void store(int index, long value)
           
protected  void store(int index, short value)
           
 
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, protectedArray, protectedArrayOffset, protectedHasArray, 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

backingArray

protected final byte[] backingArray

offset

protected final int offset
Constructor Detail

HeapByteBuffer

HeapByteBuffer(byte[] backingArray)

HeapByteBuffer

HeapByteBuffer(int capacity)

HeapByteBuffer

HeapByteBuffer(byte[] backingArray,
               int capacity,
               int offset)
Method Detail

get

public final ByteBuffer get(byte[] dest,
                            int off,
                            int len)
Description copied from class: ByteBuffer
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.

Overrides:
get in class ByteBuffer
Parameters:
dest - The target byte array
off - The offset of the byte array, must be no less than zero and no greater than dest.length
len - The number of bytes to read, must be no less than zero and no greater than dest.length - off
Returns:
This buffer

get

public final byte get()
Description copied from class: ByteBuffer
Returns the byte at the current position and increase the position by 1.

Specified by:
get in class ByteBuffer
Returns:
The byte at the current position.

get

public final byte get(int index)
Description copied from class: ByteBuffer
Returns a byte at the specified index, and the position is not changed.

Specified by:
get in class ByteBuffer
Parameters:
index - The index, must be no less than zero and less than limit
Returns:
A byte at the specified index.

getDouble

public final double getDouble()
Description copied from class: ByteBuffer
Returns the double at the current position and increase the position by 8.

The 8 bytes start from the current position are composed into a double according to current byte order and returned. The position increases by 8.

Specified by:
getDouble in class ByteBuffer
Returns:
The double at the current position.

getDouble

public final double getDouble(int index)
Description copied from class: ByteBuffer
Returns the double at the specified index.

The 8 bytes start from the specified index are composed into a double according to current byte order and returned. The position is not changed.

Specified by:
getDouble in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
Returns:
The double at the specified index.

getFloat

public final float getFloat()
Description copied from class: ByteBuffer
Returns the float at the current position and increase the position by 4.

The 4 bytes start from the current position are composed into a float according to current byte order and returned. The position increases by 4.

Specified by:
getFloat in class ByteBuffer
Returns:
The float at the current position.

getFloat

public final float getFloat(int index)
Description copied from class: ByteBuffer
Returns the float at the specified index.

The 4 bytes start from the specified index are composed into a float according to current byte order and returned. The position is not changed.

Specified by:
getFloat in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
Returns:
The float at the specified index.

getInt

public final int getInt()
Description copied from class: ByteBuffer
Returns the int at the current position and increase the position by 4.

The 4 bytes start from the current position are composed into a int according to current byte order and returned. The position increases by 4.

Specified by:
getInt in class ByteBuffer
Returns:
The int at the current position.

getInt

public final int getInt(int index)
Description copied from class: ByteBuffer
Returns the int at the specified index.

The 4 bytes start from the specified index are composed into a int according to current byte order and returned. The position is not changed.

Specified by:
getInt in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 4
Returns:
The int at the specified index.

getLong

public final long getLong()
Description copied from class: ByteBuffer
Returns the long at the current position and increase the position by 8.

The 8 bytes start from the current position are composed into a long according to current byte order and returned. The position increases by 8.

Specified by:
getLong in class ByteBuffer
Returns:
The long at the current position.

getLong

public final long getLong(int index)
Description copied from class: ByteBuffer
Returns the long at the specified index.

The 8 bytes start from the specified index are composed into a long according to current byte order and returned. The position is not changed.

Specified by:
getLong in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 8
Returns:
The long at the specified index.

getShort

public final short getShort()
Description copied from class: ByteBuffer
Returns the short at the current position and increase the position by 2.

The 2 bytes start from the current position are composed into a short according to current byte order and returned. The position increases by 2.

Specified by:
getShort in class ByteBuffer
Returns:
The short at the current position.

getShort

public final short getShort(int index)
Description copied from class: ByteBuffer
Returns the short at the specified index.

The 2 bytes start from the specified index are composed into a short according to current byte order and returned. The position is not changed.

Specified by:
getShort in class ByteBuffer
Parameters:
index - The index, must be no less than zero and equal or less than limit - 2
Returns:
The short at the specified index.

isDirect

public final boolean isDirect()
Description copied from class: ByteBuffer
Returns true if this buffer is direct.

A byte buffer is direct, if it is based on a byte buffer and the byte buffer is direct.

Specified by:
isDirect in class ByteBuffer
Returns:
True if this buffer is direct.

loadInt

protected final int loadInt(int index)

loadLong

protected final long loadLong(int index)

loadShort

protected final short loadShort(int index)

store

protected final void store(int index,
                           int value)

store

protected final void store(int index,
                           long value)

store

protected final void store(int index,
                           short value)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature