com.jniwrapper
Class ExternalArrayPointer

java.lang.Object
  extended by com.jniwrapper.Parameter
      extended by com.jniwrapper.Pointer
          extended by com.jniwrapper.ExternalArrayPointer
All Implemented Interfaces:
PointerParameter

public class ExternalArrayPointer
extends Pointer

A pointer to an array returned from the native code. Use this pointer when the returned array size is not known before the native code returns.

Memory allocated to this array is considered external and, therefore, cannot be reallocated and will not be freed by JNIWrapper. If the passed array is correctly reallocated by the caller, use ResizingPointer instead of this class.

Since:
1.1

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jniwrapper.Pointer
Pointer.Const, Pointer.OutOnly, Pointer.Void
 
Field Summary
 
Fields inherited from class com.jniwrapper.Pointer
POINTER_LENGTH
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
ExternalArrayPointer(ArrayParameter array)
          Constructs a new pointer to the given array.
ExternalArrayPointer(ArrayParameter array, boolean isNull)
          Constructs a new pointer to the given array.
 
Method Summary
 Parameter getReferencedObject()
          Returns the referenced object of this pointer.
 void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Reads this parameter from a specified data source.
 void readArray(int count)
          Reads the resized array.
protected  void readReferencedObject(boolean invokedByCallback)
          Reads the referenced object only.
protected  void setExternalSource(long newHandle, int length)
          Makes this pointer use external (unmanaged) memory area.
 void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Writes this parameter to a specified data source.
 
Methods inherited from class com.jniwrapper.Pointer
acceptIOPerformer, asTypedPointer, asVoidPointer, castTo, castTo, checkMemHandleLength, clone, equals, getDebugInfo, getLength, getParameterClass, getPointerHandle, isNull, pop, push, read, readPointer, setNull, setReferencedObject, setReferencedObject, write, writePointer, writeReferencedObject
 
Methods inherited from class com.jniwrapper.Parameter
asReturnValue, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, hashCode, indent, read, setDataBuffer, toByteArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalArrayPointer

public ExternalArrayPointer(ArrayParameter array)
Constructs a new pointer to the given array.


ExternalArrayPointer

public ExternalArrayPointer(ArrayParameter array,
                            boolean isNull)
Constructs a new pointer to the given array.

Parameters:
array -
isNull - the pointer passed to the function will be initially null if this parameter is true true.
Method Detail

read

public void read(DataBuffer stackBuffer,
                 int offset,
                 boolean invokedByCallback)
          throws MemoryAccessViolationException
Description copied from class: Parameter
Reads this parameter from a specified data source.

Overrides:
read in class Pointer
Throws:
MemoryAccessViolationException

write

public void write(DataBuffer stackBuffer,
                  int offset,
                  boolean invokedByCallback)
           throws MemoryAccessViolationException
Description copied from class: Parameter
Writes this parameter to a specified data source.

Overrides:
write in class Pointer
Throws:
MemoryAccessViolationException

readReferencedObject

protected void readReferencedObject(boolean invokedByCallback)
Description copied from class: Pointer
Reads the referenced object only. No checking is performed for memory block size or even location validity.

Overrides:
readReferencedObject in class Pointer

getReferencedObject

public Parameter getReferencedObject()
Description copied from class: Pointer
Returns the referenced object of this pointer.

Overrides:
getReferencedObject in class Pointer

setExternalSource

protected void setExternalSource(long newHandle,
                                 int length)
Description copied from class: Pointer
Makes this pointer use external (unmanaged) memory area.

Overrides:
setExternalSource in class Pointer
Parameters:
newHandle - memory handle
length - known allocated length

readArray

public void readArray(int count)
Reads the resized array.

Parameters:
count - new element count.