gov.llnl.sidl

Class BaseArray

Known Direct 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

BaseArray()
Construct an empty array object.
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.

Field Details

d_array

protected long d_array

d_owner

protected boolean d_owner

Constructor Details

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 Details

_addRef

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

_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.

_dim

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

_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.

_length

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

_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.

_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.

_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

_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.

_type

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

_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.

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.

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.

checkNullArray

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

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.

dim

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

finalize

protected void finalize()
            throws Throwable
The finalizer of this object deallocates the IOR array reference if we are the owner and the referece is not 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!

get_owner

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

isNull

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

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.

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.

reset

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

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!

set_owner

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

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.

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.