com.jniwrapper
Class ComplexArray

java.lang.Object
  extended by com.jniwrapper.Parameter
      extended by com.jniwrapper.Structure
          extended by com.jniwrapper.ComplexArray
All Implemented Interfaces:
AlignmentAwareParameter, ArrayParameter, CompositeParameter

public class ComplexArray
extends Structure
implements ArrayParameter

Represents an array of objects.

All objects in the array must have the same type.

Note: If a function takes an array as its parameter, you should take Pointer referencing that ComplexArray object, instead of direct taking the ComplexArray instance.


Field Summary
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
ComplexArray(Parameter[] arr)
          Constructs an array object taking a specified Parameter array.
ComplexArray(Parameter sample, int count)
          Constructs an array object.
 
Method Summary
protected  void acceptIOPerformer(IOPerformer performer, DataBuffer source, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
          Implementation of a Visitor pattern for parameter IO.
static void arrayCopy(ComplexArray from, ComplexArray to)
          Copy ComplexArray content
 java.lang.Object clone()
           
 void forceElementCount(int elementCount)
          Sets a new array size without memory reallocation.
 void fromParameterArray(Parameter[] params)
          Sets array contents to the given values.
 int getAlignmentRequirement()
           
 Parameter getElement(int i)
          Returns an array item specified by an index.
 int getElementCount()
          Returns the number of elements in the array.
 void pop(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Default implementation that does nothing because most primitive types do nothing on pop.
 void push(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Writes a parameter to a function stacks.
 void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Reads this parameter from a specified data source.
protected  void setDataBuffer(DataBuffer newSource, int newOffset, boolean shouldRead)
          Sets the data buffer this parameter should use to store data and an offset in bytes within that buffer.
 void setElement(int i, Parameter elem)
          Replaces an array item with the specified object.
 void setElementCount(int elementCount)
          Resizes this array to a given size.
 Parameter[] toParameterArray()
          Returns items as Java array.
 java.lang.String toString()
           
 void write(byte[] arr, int offset)
          Writes the parameter value to a byte array.
 void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
          Writes this parameter to a specified data source.
 
Methods inherited from class com.jniwrapper.Structure
addMembers, computeLength, equals, getDebugInfo, getFirstMemberSize, getLength, getMember, getMembers, getOffsets, init, init, initFrom
 
Methods inherited from class com.jniwrapper.Parameter
asReturnValue, dataBufferAssigned, getAlignedLength, getDataBuffer, getDataBufferOffset, hashCode, indent, read, read, toByteArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComplexArray

public ComplexArray(Parameter[] arr)
Constructs an array object taking a specified Parameter array.


ComplexArray

public ComplexArray(Parameter sample,
                    int count)
Constructs an array object. Fills it with copies of a sample object.

Parameters:
sample - a sample for items in the constructed array
count - count of items in the constructed array
Method Detail

write

public void write(byte[] arr,
                  int offset)
Description copied from class: Parameter
Writes the parameter value to a byte array.

Overrides:
write in class Parameter

clone

public java.lang.Object clone()
Overrides:
clone in class Structure

getElement

public Parameter getElement(int i)
Description copied from interface: ArrayParameter
Returns an array item specified by an index.

Specified by:
getElement in interface ArrayParameter
Parameters:
i - index of a requested array item

setElement

public void setElement(int i,
                       Parameter elem)
Description copied from interface: ArrayParameter
Replaces an array item with the specified object.

Specified by:
setElement in interface ArrayParameter
Parameters:
i - index of an item to be replaced
elem - object to be set as array item

setDataBuffer

protected void setDataBuffer(DataBuffer newSource,
                             int newOffset,
                             boolean shouldRead)
Description copied from class: Parameter
Sets the data buffer this parameter should use to store data and an offset in bytes within that buffer.

Overrides:
setDataBuffer in class Structure

acceptIOPerformer

protected void acceptIOPerformer(IOPerformer performer,
                                 DataBuffer source,
                                 int initialOffset,
                                 boolean isReadOperation,
                                 boolean invokedByCallback)
Description copied from class: Parameter
Implementation of a Visitor pattern for parameter IO. A performer is responsible for reading and writing the parameter. Users implementing a complex parameter from scratch (i.e. not by extending a pre-existing class such as Structure or Pointer) may wish to override this method to make a performer visit object internal parts.

Overrides:
acceptIOPerformer in class Structure
Parameters:
performer - a visitor responsible for I/Oing the parameter.
source - data buffer for I/O operation.
initialOffset - I/O operation offset of this parameter in the buffer.

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 Structure
Throws:
MemoryAccessViolationException

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 Structure
Throws:
MemoryAccessViolationException

push

public void push(DataBuffer stackBuffer,
                 int offset,
                 boolean invokedByCallback)
          throws MemoryAccessViolationException
Description copied from class: Parameter
Writes a parameter to a function stacks.

Overrides:
push in class Structure
Throws:
MemoryAccessViolationException

pop

public void pop(DataBuffer stackBuffer,
                int offset,
                boolean invokedByCallback)
         throws MemoryAccessViolationException
Description copied from class: Parameter
Default implementation that does nothing because most primitive types do nothing on pop. Reads a parameter from a function stack.

Overrides:
pop in class Structure
Throws:
MemoryAccessViolationException

getElementCount

public int getElementCount()
Description copied from interface: ArrayParameter
Returns the number of elements in the array.

Specified by:
getElementCount in interface ArrayParameter

toParameterArray

public Parameter[] toParameterArray()
Description copied from interface: ArrayParameter
Returns items as Java array.

Specified by:
toParameterArray in interface ArrayParameter

fromParameterArray

public void fromParameterArray(Parameter[] params)
Description copied from interface: ArrayParameter
Sets array contents to the given values.

Specified by:
fromParameterArray in interface ArrayParameter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

forceElementCount

public void forceElementCount(int elementCount)
Description copied from interface: ArrayParameter
Sets a new array size without memory reallocation. This method should be used with caution as the array may access invalid memory area if an incorrect value is passed in the argument.

Specified by:
forceElementCount in interface ArrayParameter

setElementCount

public void setElementCount(int elementCount)
Description copied from interface: ArrayParameter
Resizes this array to a given size.

Specified by:
setElementCount in interface ArrayParameter

arrayCopy

public static void arrayCopy(ComplexArray from,
                             ComplexArray to)
Copy ComplexArray content

Parameters:
from - source
to - destination

getAlignmentRequirement

public int getAlignmentRequirement()
Overrides:
getAlignmentRequirement in class Structure
Returns:
required alignment within a structure or an array