javax.media.ding3d.internal
Class ByteBufferWrapper

java.lang.Object
  extended by javax.media.ding3d.internal.BufferWrapper
      extended by javax.media.ding3d.internal.ByteBufferWrapper

public class ByteBufferWrapper
extends BufferWrapper

NIO Buffers are new in Java 1.4 but we need to run on 1.3 as well, so this class was created to hide the NIO classes from non-1.4 Java 3D users.

NOTE: We no longer need to support JDK 1.3 as of the Java 3D 1.3.2 community source release on java.net. We should be able to get rid of this class.


Field Summary
 
Fields inherited from class javax.media.ding3d.internal.BufferWrapper
TYPE_BYTE, TYPE_DOUBLE, TYPE_FLOAT, TYPE_NULL, TYPE_UNKNOWN
 
Constructor Summary
ByteBufferWrapper(java.nio.ByteBuffer buffer)
          Constructor initializes buffer with a java.nio.ByteBuffer object.
ByteBufferWrapper(Ding3dBuffer b)
          Constructor initializes buffer with a javax.media.ding3d.Ding3dBuffer object.
 
Method Summary
static ByteBufferWrapper allocateDirect(int capacity)
          Allocate a direct ByteBuffer with the given capacity.
 DoubleBufferWrapper asDoubleBuffer()
          Creates a view of this ByteBufferWrapper as a DoubleBufferWrapper.
 FloatBufferWrapper asFloatBuffer()
          Creates a view of this ByteBufferWrapper as a FloatBufferWrapper.
 byte get()
          Reads the byte at this buffer's current position, and then increments the position.
 ByteBufferWrapper get(byte[] dst)
          Bulk get method.
 ByteBufferWrapper get(byte[] dst, int offset, int length)
          Bulk get method.
 byte get(int index)
          Reads the byte at the given offset into the buffer.
 java.nio.Buffer getBuffer()
          Returns the java.nio.Buffer contained within this ByteBufferWrapper.
 Ding3dBuffer getDing3dBuffer()
          Creates and returns a Ding3dBuffer object containing the buffer in this ByteBufferWrapper object.
 boolean isDirect()
           
 ByteOrderWrapper order()
          Returns the byte order of this buffer.
 ByteBufferWrapper order(ByteOrderWrapper bo)
          Modifies this buffer's byte order.
 ByteBufferWrapper put(byte[] src)
          Bulk put method.
 
Methods inherited from class javax.media.ding3d.internal.BufferWrapper
capacity, getBufferAsObject, getBufferType, limit, position, position, rewind
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteBufferWrapper

public ByteBufferWrapper(java.nio.ByteBuffer buffer)
Constructor initializes buffer with a java.nio.ByteBuffer object.


ByteBufferWrapper

public ByteBufferWrapper(Ding3dBuffer b)
Constructor initializes buffer with a javax.media.ding3d.Ding3dBuffer object.

Method Detail

allocateDirect

public static ByteBufferWrapper allocateDirect(int capacity)
Allocate a direct ByteBuffer with the given capacity.

Returns:
New ByteBufferWrapper containing the new buffer.

getBuffer

public java.nio.Buffer getBuffer()
Returns the java.nio.Buffer contained within this ByteBufferWrapper.


isDirect

public boolean isDirect()
Returns:
A boolean indicating whether the java.nio.Buffer object contained within this ByteBuffer is direct or indirect.

get

public byte get()
Reads the byte at this buffer's current position, and then increments the position.


get

public byte get(int index)
Reads the byte at the given offset into the buffer.


get

public ByteBufferWrapper get(byte[] dst)
Bulk get method. Transfers dst.length bytes from the buffer to the destination array and increments the buffer's position by dst.length.


get

public ByteBufferWrapper get(byte[] dst,
                             int offset,
                             int length)
Bulk get method. Transfers length bytes from the buffer starting at position offset into the destination array.


order

public ByteOrderWrapper order()
Returns the byte order of this buffer.


order

public ByteBufferWrapper order(ByteOrderWrapper bo)
Modifies this buffer's byte order.


asFloatBuffer

public FloatBufferWrapper asFloatBuffer()
Creates a view of this ByteBufferWrapper as a FloatBufferWrapper. Uses the correct


asDoubleBuffer

public DoubleBufferWrapper asDoubleBuffer()
Creates a view of this ByteBufferWrapper as a DoubleBufferWrapper.


put

public ByteBufferWrapper put(byte[] src)
Bulk put method. Transfers src.length bytes into the buffer at the current position.


getDing3dBuffer

public Ding3dBuffer getDing3dBuffer()
Creates and returns a Ding3dBuffer object containing the buffer in this ByteBufferWrapper object.