com.jniwrapper
Class PrimitiveArray

java.lang.Object
  |
  +--com.jniwrapper.Parameter
        |
        +--com.jniwrapper.PrimitiveArray
All Implemented Interfaces:
ArrayParameter

public class PrimitiveArray
extends Parameter
implements ArrayParameter

Represents an array of primitive types such as array of bytes or array of integer values. All array items are instances of the same class.


Constructor Summary
PrimitiveArray(byte[] data)
          Constructs byte array and fills it with specified data.
PrimitiveArray(byte[] buf, java.lang.Class entriesClass)
          Constructs array of objects of specified class and fills it with corresponding data.
PrimitiveArray(java.lang.Class entriesClass, int count)
          Constructs an array and fills it with instances of specified class.
PrimitiveArray(Parameter[] params)
          Constructs array object taking specified Parameter array.
PrimitiveArray(Parameter sample, int count)
          Constructs array object.
PrimitiveArray(PrimitiveArray t)
          Constructs a copy of specified array.
 
Method Summary
 java.lang.Object clone()
           
 void fromParameterArray(Parameter[] params)
          Sets array content to the given values
 byte[] getBytes()
          Returns byte data of an array.
 Parameter getElement(int i)
          Returns array item specified by an index
 int getElementCount()
          Returns items count
 java.lang.Class getEntryClass()
          Returns a class of array items.
 int getLength()
          Returns length of the array data in bytes.
 void read(DataBuffer stackBuffer, int offset)
          Reads this parameter from a specified data source.
 void readPartially(byte[] arr, int offset)
          Reads raw data from a given array into this object's data source.
 void resizeAndRead(byte[] arr, int offset, int dataLength)
          Sets new size of this array and reads it from given byte array.
 void setElement(int i, Parameter elem)
          Replaces array item by 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(DataBuffer stackBuffer, int offset)
          Writes this parameter to a specified data source.
 
Methods inherited from class com.jniwrapper.Parameter
acceptIOPerformer, asReturnValue, equals, getAlignedLength, getBuffer, getOffset, indent, pop, push, read, setBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrimitiveArray

public PrimitiveArray(PrimitiveArray t)
Constructs a copy of specified array.


PrimitiveArray

public PrimitiveArray(java.lang.Class entriesClass,
                      int count)
Constructs an array and fills it with instances of specified class.

Parameters:
entriesClass - Class of array items
count - Count of array items

PrimitiveArray

public PrimitiveArray(byte[] data)
Constructs byte array and fills it with specified data.


PrimitiveArray

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

Parameters:
sample - Sample for items in constructed array
count - Count of items in constructed array

PrimitiveArray

public PrimitiveArray(byte[] buf,
                      java.lang.Class entriesClass)
Constructs array of objects of specified class and fills it with corresponding data.


PrimitiveArray

public PrimitiveArray(Parameter[] params)
Constructs array object taking specified Parameter array.

Method Detail

getEntryClass

public java.lang.Class getEntryClass()
Returns a class of array items.


getLength

public int getLength()
Returns length of the array data in bytes.

Specified by:
getLength in class Parameter

getBytes

public byte[] getBytes()
Returns byte data of an array.


clone

public java.lang.Object clone()
Specified by:
clone in class Parameter

toString

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

getElement

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

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

setElement

public void setElement(int i,
                       Parameter elem)
Description copied from interface: ArrayParameter
Replaces array item by 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

getElementCount

public int getElementCount()
Description copied from interface: ArrayParameter
Returns items count

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 content to the given values

Specified by:
fromParameterArray in interface ArrayParameter

write

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

Specified by:
write in class Parameter
MemoryAccessViolationException

read

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

Specified by:
read in class Parameter
MemoryAccessViolationException

readPartially

public void readPartially(byte[] arr,
                          int offset)
Reads raw data from a given array into this object's data source. This is equal to a read(byte[] arr, int offset) where data beyond given array length in source array is unspecified.


resizeAndRead

public void resizeAndRead(byte[] arr,
                          int offset,
                          int dataLength)
Sets new size of this array and reads it from given byte array.

Parameters:
arr - new array raw (as in memory) contents.
offset - where this parameter starts in arr
dataLength - raw length of this array (sizeof(element) * elementCount)

setElementCount

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

Specified by:
setElementCount in interface ArrayParameter