org.jocl
Class Pointer

java.lang.Object
  extended by org.jocl.NativePointerObject
      extended by org.jocl.Pointer

public final class Pointer
extends NativePointerObject

A Java representation of a void pointer.


Constructor Summary
  Pointer()
          Creates a new (null) Pointer
protected Pointer(java.nio.Buffer buffer)
          Creates a Pointer to the given Buffer
protected Pointer(Pointer other)
          Copy constructor
protected Pointer(Pointer other, long byteOffset)
          Creates a copy of the given pointer, with an additional byte offset
 
Method Summary
static Pointer to(java.nio.Buffer buffer)
          Creates a new Pointer to the given Buffer.
static Pointer to(byte[] values)
          Creates a new Pointer to the given values.
static Pointer to(char[] values)
          Creates a new Pointer to the given values.
static Pointer to(double[] values)
          Creates a new Pointer to the given values.
static Pointer to(float[] values)
          Creates a new Pointer to the given values.
static Pointer to(int[] values)
          Creates a new Pointer to the given values.
static Pointer to(long[] values)
          Creates a new Pointer to the given values.
static Pointer to(NativePointerObject... pointers)
          Creates a new Pointer to the given Pointers.
static Pointer to(short[] values)
          Creates a new Pointer to the given values.
 Pointer withByteOffset(long byteOffset)
          Returns a new pointer with an offset of the given number of bytes
 
Methods inherited from class org.jocl.NativePointerObject
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pointer

public Pointer()
Creates a new (null) Pointer


Pointer

protected Pointer(java.nio.Buffer buffer)
Creates a Pointer to the given Buffer

Parameters:
buffer - The buffer to point to

Pointer

protected Pointer(Pointer other)
Copy constructor

Parameters:
other - The other Pointer

Pointer

protected Pointer(Pointer other,
                  long byteOffset)
Creates a copy of the given pointer, with an additional byte offset

Parameters:
other - The other pointer
byteOffset - The additional byte offset
Method Detail

to

public static Pointer to(byte[] values)
Creates a new Pointer to the given values.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(char[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(short[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(int[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(float[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(long[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(double[] values)
Creates a new Pointer to the given values. The values may not be null.

Parameters:
values - The values the pointer should point to
Returns:
The pointer

to

public static Pointer to(java.nio.Buffer buffer)
Creates a new Pointer to the given Buffer. The buffer must not be null, and either be a direct buffer, or have a backing array.

Parameters:
buffer - The buffer the pointer should point to
Returns:
The pointer
Throws:
java.lang.IllegalArgumentException - If the given buffer is null or is neither direct nor has a backing array

to

public static Pointer to(NativePointerObject... pointers)
Creates a new Pointer to the given Pointers. The array of pointers may not be null, and may not contain null elements.

Parameters:
pointers - The pointers the pointer should point to
Returns:
The new pointer
Throws:
java.lang.IllegalArgumentException - If the given array is null

withByteOffset

public Pointer withByteOffset(long byteOffset)
Returns a new pointer with an offset of the given number of bytes

Parameters:
byteOffset - The byte offset for the pointer
Returns:
The new pointer with the given byte offset