gov.llnl.sidl
Class BaseArray

java.lang.Object
  extended by gov.llnl.sidl.BaseArray
Direct Known Subclasses:
Boolean.Array, Character.Array, Double.Array, DoubleComplex.Array, Float.Array, FloatComplex.Array, Integer.Array, Long.Array, Opaque.Array, String.Array

public abstract class BaseArray
extends java.lang.Object

Class BaseArray is the base array for all sidl Java arrays in the run-time system. This class provides basic support for bounds checking and management of the IOR array pointer object.


Nested Class Summary
static class BaseArray.Holder
          Holder class for inout and out arguments.
 
Field Summary
protected  long d_array
           
protected  boolean d_owner
           
 
Constructor Summary
protected BaseArray()
          Construct an empty array object.
protected BaseArray(long array, boolean owner)
          Create an array using an IOR array pointer.
 
Method Summary
 void _addRef()
          Native method adds 1 to array's reference count.
 void _deallocate()
          Deallocate deletes java's reference to the array (calls deleteRef) But does not (nessecarily) case the array to be GCed.
 void _destroy()
          Native method to destroy the array.
 int _dim()
          Native method to get the dimension of the array.
 boolean _isColumnOrder()
          Native method returns true if array is ColumnOrder.
 boolean _isRowOrder()
          Native method returns true if array if RowOrder.
 int _length(int dim)
          Routine to get the length of the array at the specified dimension
 int _lower(int dim)
          Native method to fetch the specified lower bound of the array.
abstract  void _reallocate(int dim, int[] lower, int[] upper, boolean isRow)
          Abstract method to reallocate array data using the specified dimension, lower bounds, and upper bounds.
 BaseArray _smartCopy()
          Method smartCopy returns a a copy of a borrowed array, or increments the reference count of an array that manages it's own data.
 int _stride(int dim)
          Native method to fetch the stride of the specified dimen of the array.
 int _type()
          Native method returns the enumerated type of this array
 int _upper(int dim)
          Native method to fetch the specified upper bound of the array.
protected  void checkBounds(int i)
          Check that the index is valid for the array.
protected  void checkBounds(int i, int j)
          Check that the indices are valid for the array.
protected  void checkBounds(int i, int j, int k)
          Check that the indices are valid for the array.
protected  void checkBounds(int i, int j, int k, int l)
          Check that the indices are valid for the array.
protected  void checkBounds(int i, int j, int k, int l, int m)
          Check that the indices are valid for the array.
protected  void checkBounds(int i, int j, int k, int l, int m, int n)
          Check that the indices are valid for the array.
protected  void checkBounds(int i, int j, int k, int l, int m, int n, int o)
          Check that the indices are valid for the array.
protected  void checkDimension(int d)
          Check that the array is equal to the specified rank.
protected  void checkIndexBounds(int i, int d)
          Check that the index is valid for the specified dimension.
protected  void checkNullArray()
          Throw a NullPointerException if the array is null.
 void destroy()
          Destroy the existing array and make it null.
 int dim()
          Return the dimension of the array.
protected  void finalize()
          The finalizer of this object deallocates the IOR array reference if we are the owner and the referece is not null.
 long get_ior_pointer()
          Return the pointer to the implementation of the Array (A special function for Object arrays, No touchie!
 boolean get_owner()
          Return the array owner flag (A special function for Object arrays, No touchie!
 boolean isNull()
          Check whether the array referenced by this object is null.
 int lower(int dim)
          Return the lower index of the array corresponding to the specified array dimension.
 void reallocate(int dim, int[] lower, int[] upper, boolean isRow)
          Reallocate array data using the specified dimension and lower and upper bounds.
protected  void reset(long array, boolean owner)
          Destroy existing array data (if present and owner) and assign the new array pointer and owner.
 void set_ior_pointer(long p)
          Set the pointer to the implementation of the Array (A special function for Object arrays, No touchie!
 void set_owner(boolean p)
          Return the array owner flag (A special function for Object arrays, No touchie!
 int stride(int dim)
          Return the stride of the array corresponding to the specified array dimension.
 int upper(int dim)
          Return the upper index of the array corresponding to the specified array dimension.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

d_array

protected long d_array

d_owner

protected boolean d_owner
Constructor Detail

BaseArray

protected BaseArray()
Construct an empty array object. This object must be allocated before any actions are performed on the array data.


BaseArray

protected BaseArray(long array,
                    boolean owner)
Create an array using an IOR array pointer. The pointer value may be zero (representing null). If the owner flag is true, then the array will be deallocated when this object disappears.

Method Detail

reset

protected void reset(long array,
                     boolean owner)
Destroy existing array data (if present and owner) and assign the new array pointer and owner.


isNull

public boolean isNull()
Check whether the array referenced by this object is null.


_type

public int _type()
Native method returns the enumerated type of this array


_dim

public int _dim()
Native method to get the dimension of the array. This method will be implemented in subclasses as a native method.


_lower

public int _lower(int dim)
Native method to fetch the specified lower bound of the array. This method will be implemented in subclasses as a native method. The specified array dimension must be between zero and the array dimension minus one. Invalid values will have unpredictable (but almost certainly bad) results.


_upper

public int _upper(int dim)
Native method to fetch the specified upper bound of the array. This method will be implemented in subclasses as a native method. The specified array dimension must be between zero and the array dimension minus one. Invalid values will have unpredictable (but almost certainly bad) results.


_length

public int _length(int dim)
Routine to get the length of the array at the specified dimension


_stride

public int _stride(int dim)
Native method to fetch the stride of the specified dimen of the array. This method will be implemented in subclasses as a native method. The specified array dimension must be between zero and the array dimension minus one. Invalid values will have unpredictable (but almost certainly bad) results.


_isColumnOrder

public boolean _isColumnOrder()
Native method returns true if array is ColumnOrder. This method will be implemented in subclasses as a native method.


_isRowOrder

public boolean _isRowOrder()
Native method returns true if array if RowOrder. This method will be implemented in subclasses as a native method.


_addRef

public void _addRef()
Native method adds 1 to array's reference count. Not for users but for internal babel stuff.


_smartCopy

public BaseArray _smartCopy()
Method smartCopy returns a a copy of a borrowed array, or increments the reference count of an array that manages it's own data. Useful if you wish to keep a copy of an incoming array


_deallocate

public void _deallocate()
Deallocate deletes java's reference to the array (calls deleteRef) But does not (nessecarily) case the array to be GCed.


_destroy

public void _destroy()
Native method to destroy the array. This will be called by the object finalizer if the array is owned by this object.


_reallocate

public abstract void _reallocate(int dim,
                                 int[] lower,
                                 int[] upper,
                                 boolean isRow)
Abstract method to reallocate array data using the specified dimension, lower bounds, and upper bounds. This routine assumes that the dimension and indices are valid.


destroy

public void destroy()
Destroy the existing array and make it null. This method deallocates the IOR array reference if we are the owner and the reference is not null. The new array reference is null.


get_ior_pointer

public long get_ior_pointer()
Return the pointer to the implementation of the Array (A special function for Object arrays, No touchie!


set_ior_pointer

public void set_ior_pointer(long p)
Set the pointer to the implementation of the Array (A special function for Object arrays, No touchie!


get_owner

public boolean get_owner()
Return the array owner flag (A special function for Object arrays, No touchie!


set_owner

public void set_owner(boolean p)
Return the array owner flag (A special function for Object arrays, No touchie!


finalize

protected void finalize()
                 throws java.lang.Throwable
The finalizer of this object deallocates the IOR array reference if we are the owner and the referece is not null.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

reallocate

public void reallocate(int dim,
                       int[] lower,
                       int[] upper,
                       boolean isRow)
Reallocate array data using the specified dimension and lower and upper bounds. Old array data is deleted. Each of the lower and upper bounds arrays must contain dim elements. Upper array bounds are inclusive. An array index out of bounds exception is thrown if any of the indices are invalid.


dim

public int dim()
Return the dimension of the array. If the array is null, then the dimension is zero.


checkNullArray

protected void checkNullArray()
Throw a NullPointerException if the array is null.


checkDimension

protected void checkDimension(int d)
Check that the array is equal to the specified rank. If the array ranks do not match, an ArrayIndexOutOfBoundsException is thrown. This routine assumes that the array is not null.


checkIndexBounds

protected void checkIndexBounds(int i,
                                int d)
Check that the index is valid for the specified dimension. An ArrayIndexOutOfBoundsException is thrown if the index is out of bounds. This routine assumes both that the array pointer is not null and that the dimension argument is valid.


checkBounds

protected void checkBounds(int i)
Check that the index is valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j,
                           int k)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j,
                           int k,
                           int l)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j,
                           int k,
                           int l,
                           int m)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j,
                           int k,
                           int l,
                           int m,
                           int n)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


checkBounds

protected void checkBounds(int i,
                           int j,
                           int k,
                           int l,
                           int m,
                           int n,
                           int o)
Check that the indices are valid for the array. A null pointer exception is thrown if the arry is null. An array index out of bounds exception is thrown if the index is out of bounds.


lower

public int lower(int dim)
Return the lower index of the array corresponding to the specified array dimension. This routine will throw a null pointer exception if the object is null or an array index out of bounds exception if the specified array dimension is not valid.


upper

public int upper(int dim)
Return the upper index of the array corresponding to the specified array dimension. The array runs from the lower bound to the upper bound, inclusive. This routine will throw a null pointer exception if the object is null or an array index out of bounds exception if the specified array dimension is not valid.


stride

public int stride(int dim)
Return the stride of the array corresponding to the specified array dimension. This routine will throw a null pointer exception if the object is null or an array index out of bounds exception if the specified array dimension is not valid.