java.nio.DirectByteBuffer Class Reference

Inheritance diagram for java.nio.DirectByteBuffer:

java.nio.BaseByteBuffer java.nio.ByteBuffer java.nio.Buffer java.nio.ReadOnlyDirectByteBuffer java.nio.ReadWriteDirectByteBuffer

List of all members.


Detailed Description

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.

Public Member Functions

final 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.
final byte get ()
 Returns the byte at the current position and increase the position by 1.
final byte get (int index)
 Returns a byte at the specified index, and the position is not changed.
final double getDouble ()
 Returns the double at the current position and increase the position by 8.
final double getDouble (int index)
 Returns the double at the specified index.
final float getFloat ()
 Returns the float at the current position and increase the position by 4.
final float getFloat (int index)
 Returns the float at the specified index.
final int getInt ()
 Returns the int at the current position and increase the position by 4.
final int getInt (int index)
 Returns the int at the specified index.
final long getLong ()
 Returns the long at the current position and increase the position by 8.
final long getLong (int index)
 Returns the long at the specified index.
final short getShort ()
 Returns the short at the current position and increase the position by 2.
final short getShort (int index)
 Returns the short at the specified index.
final boolean isDirect ()
 Returns true if this buffer is direct.
final boolean isAddressValid ()
final void addressValidityCheck ()
final PlatformAddress getBaseAddress ()
final PlatformAddress getEffectiveAddress ()
 Answers the platform address of the start of this buffer instance.
final void free ()
 Explicitly free the memory used by this direct byte buffer.
final int getByteCapacity ()

Protected Member Functions

final byte[] protectedArray ()
 Child class implements this method to realize array().
final int protectedArrayOffset ()
 Child class implements this method to realize arrayOffset().
final boolean protectedHasArray ()
 Child class implements this method to realize hasArray().

Protected Attributes

final SafeAddress safeAddress
final int offset

Package Functions

 DirectByteBuffer (int capacity)
 DirectByteBuffer (SafeAddress address, int capacity, int offset)

Classes

class  SafeAddress


Constructor & Destructor Documentation

java.nio.DirectByteBuffer.DirectByteBuffer ( int  capacity  )  [package]

java.nio.DirectByteBuffer.DirectByteBuffer ( SafeAddress  address,
int  capacity,
int  offset 
) [package]


Member Function Documentation

final ByteBuffer java.nio.DirectByteBuffer.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.

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
Exceptions:
IndexOutOfBoundsException If either off or len is invalid
BufferUnderflowException If len is greater than remaining()

Reimplemented from java.nio.ByteBuffer.

final byte java.nio.DirectByteBuffer.get (  )  [virtual]

Returns the byte at the current position and increase the position by 1.

Returns:
The byte at the current position.
Exceptions:
BufferUnderflowException If the position is equal or greater than limit

Implements java.nio.ByteBuffer.

final byte java.nio.DirectByteBuffer.get ( int  index  )  [virtual]

Returns a byte at the specified index, and the position is not changed.

Parameters:
index The index, must be no less than zero and less than limit
Returns:
A byte at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final double java.nio.DirectByteBuffer.getDouble (  )  [virtual]

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.

Returns:
The double at the current position.
Exceptions:
BufferUnderflowException If the position is greater than limit - 8

Implements java.nio.ByteBuffer.

final double java.nio.DirectByteBuffer.getDouble ( int  index  )  [virtual]

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.

Parameters:
index The index, must be no less than zero and equal or less than limit - 8
Returns:
The double at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final float java.nio.DirectByteBuffer.getFloat (  )  [virtual]

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.

Returns:
The float at the current position.
Exceptions:
BufferUnderflowException If the position is greater than limit - 4

Implements java.nio.ByteBuffer.

final float java.nio.DirectByteBuffer.getFloat ( int  index  )  [virtual]

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.

Parameters:
index The index, must be no less than zero and equal or less than limit - 4
Returns:
The float at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final int java.nio.DirectByteBuffer.getInt (  )  [virtual]

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.

Returns:
The int at the current position.
Exceptions:
BufferUnderflowException If the position is greater than limit - 4

Implements java.nio.ByteBuffer.

final int java.nio.DirectByteBuffer.getInt ( int  index  )  [virtual]

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.

Parameters:
index The index, must be no less than zero and equal or less than limit - 4
Returns:
The int at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final long java.nio.DirectByteBuffer.getLong (  )  [virtual]

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.

Returns:
The long at the current position.
Exceptions:
BufferUnderflowException If the position is greater than limit - 8

Implements java.nio.ByteBuffer.

final long java.nio.DirectByteBuffer.getLong ( int  index  )  [virtual]

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.

Parameters:
index The index, must be no less than zero and equal or less than limit - 8
Returns:
The long at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final short java.nio.DirectByteBuffer.getShort (  )  [virtual]

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.

Returns:
The short at the current position.
Exceptions:
BufferUnderflowException If the position is greater than limit - 2

Implements java.nio.ByteBuffer.

final short java.nio.DirectByteBuffer.getShort ( int  index  )  [virtual]

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.

Parameters:
index The index, must be no less than zero and equal or less than limit - 2
Returns:
The short at the specified index.
Exceptions:
IndexOutOfBoundsException If index is invalid

Implements java.nio.ByteBuffer.

final boolean java.nio.DirectByteBuffer.isDirect (  )  [virtual]

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.

Returns:
True if this buffer is direct.

Implements java.nio.ByteBuffer.

final boolean java.nio.DirectByteBuffer.isAddressValid (  ) 

final void java.nio.DirectByteBuffer.addressValidityCheck (  ) 

final PlatformAddress java.nio.DirectByteBuffer.getBaseAddress (  ) 

final PlatformAddress java.nio.DirectByteBuffer.getEffectiveAddress (  ) 

Answers the platform address of the start of this buffer instance.

You must not attempt to free the returned address!! It may not be an address that was explicitly malloc'ed (i.e. if this buffer is the result of a split); and it may be memory shared by multiple buffers.

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.

Returns:
the effective address of the start of the buffer.
Exceptions:
IllegalStateException if this buffer address is known to have been freed previously.

final void java.nio.DirectByteBuffer.free (  ) 

Explicitly free the memory used by this direct byte buffer.

If the memory has already been freed then this is a no-op. Once the memory has been freed then operations requiring access to the memory will throw an 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.

final byte [] java.nio.DirectByteBuffer.protectedArray (  )  [protected, virtual]

Child class implements this method to realize array().

Returns:
see array()

Implements java.nio.ByteBuffer.

final int java.nio.DirectByteBuffer.protectedArrayOffset (  )  [protected, virtual]

Child class implements this method to realize arrayOffset().

Returns:
see arrayOffset()

Implements java.nio.ByteBuffer.

final boolean java.nio.DirectByteBuffer.protectedHasArray (  )  [protected, virtual]

Child class implements this method to realize hasArray().

Returns:
see hasArray()

Implements java.nio.ByteBuffer.

final int java.nio.DirectByteBuffer.getByteCapacity (  ) 


Member Data Documentation

final SafeAddress java.nio.DirectByteBuffer.safeAddress [protected]

final int java.nio.DirectByteBuffer.offset [protected]


The documentation for this class was generated from the following file:

Genereated on Thu Jan 31 16:24:04 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.