com.ibm.bsf.engines.rexx
Class ArrayWrapper

java.lang.Object
  |
  +--com.ibm.bsf.engines.rexx.ArrayWrapper

public class ArrayWrapper
extends java.lang.Object

This class serves as a wrapper for Java arrays. Its methods allow to fully interact with arrays of any type from Rexx (and other non-Java-based languages). Names of methods are called after their Object Rexx counterparts, if any.

Since:
2003-02-09 by rgf
Version:
1.0.1, 2003-05-30
Author:
Rony G. Flatscher

Field Summary
protected static java.util.Hashtable array2wrapper
          This hashtable serves as a registry for arrays already analyzed by an instance of this class.
private  java.lang.Object arrayObject
          Stores the array object which this instance wraps.
 java.lang.Class componentType
          Stores the class object used for the values stored in the array.
 int dimensions
          Stores the total number of dimensions.
 int items
          Stores the total size (maximum number of entries) of the entire array.
 int[] sizeOfDimension
          Array of int which stores the size (maximum number of entries) of the appropriate dimension.
 
Constructor Summary
private ArrayWrapper(java.lang.Object objArray)
          A private constructor.
 
Method Summary
 int dimension(int i)
          Returns the size of the given dimension.
 java.lang.Object get(int[] idxArr)
          Get a value (item, element) from the array at the given position.
static com.ibm.bsf.engines.rexx.ArrayWrapper getArrayWrapper(java.lang.Object objArray)
          Only method to get an instance of ArrayWrapper created.
 java.lang.Object[] makearray(boolean bSupplier, boolean bRexxStyle)
          Modelled after Object Rexx MAKEARRAY method of the array class.
 void put(java.lang.Object valueObj, int[] idxArr)
          Put a value (item, element) into the array object at the given position.
 com.ibm.bsf.engines.rexx.Supplier supplier()
          Creates a supplier object for allowing to enumerate the array together with the appropriate indices (Java style: index starts with 0 and is enclosed in square brackets).
 com.ibm.bsf.engines.rexx.Supplier supplier(boolean bRexxStyle)
          Creates a supplier object for allowing to enumerate the array together with the appropriate indices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array2wrapper

protected static java.util.Hashtable array2wrapper
This hashtable serves as a registry for arrays already analyzed by an instance of this class.


arrayObject

private java.lang.Object arrayObject
Stores the array object which this instance wraps.


dimensions

public int dimensions
Stores the total number of dimensions.


sizeOfDimension

public int[] sizeOfDimension
Array of int which stores the size (maximum number of entries) of the appropriate dimension.


items

public int items
Stores the total size (maximum number of entries) of the entire array.


componentType

public java.lang.Class componentType
Stores the class object used for the values stored in the array.

Constructor Detail

ArrayWrapper

private ArrayWrapper(java.lang.Object objArray)
A private constructor. Gets used if there is no ArrayWrapper instance in array2wrapper.

Method Detail

dimension

public int dimension(int i)
Returns the size of the given dimension.

Returns:
the size of the given dimension.

getArrayWrapper

public static com.ibm.bsf.engines.rexx.ArrayWrapper getArrayWrapper(java.lang.Object objArray)
Only method to get an instance of ArrayWrapper created. If there is already an instance for the given array in the Hashtable array2wrapper, that instance is returned, else an instance is created, stored in the Hashtable and then returned.

Parameters:
objArray - the array object for which an ArrayWrapper instance is sought
Returns:
an ArrayWrapper instance.

get

public java.lang.Object get(int[] idxArr)
Get a value (item, element) from the array at the given position.

Parameters:
idxArr - a one-dimensional array of ints determining the location in the array.
Returns:
the Object stored at the specified location.

put

public void put(java.lang.Object valueObj,
                int[] idxArr)
Put a value (item, element) into the array object at the given position.

Parameters:
idxArr - a one-dimensional array of ints determining the location in the array.
valueObj - the Object to store; in the case of primitives the appropriate conversions takes place, curtesy of Array.

supplier

public com.ibm.bsf.engines.rexx.Supplier supplier()
Creates a supplier object for allowing to enumerate the array together with the appropriate indices (Java style: index starts with 0 and is enclosed in square brackets).

Returns:
an instance of class Supplier, allowing for enumerating the contents of the array.

supplier

public com.ibm.bsf.engines.rexx.Supplier supplier(boolean bRexxStyle)
Creates a supplier object for allowing to enumerate the array together with the appropriate indices.

Parameters:
bRexxStyle - determines whether the index value is [Object] Rexx style (index starts with 1, multiple indices are separated by a comma) or Java style (index starts with 0, indices are enclosed in square brackets)
Returns:
an instance of class Supplier, allowing for enumerating the contents of the array.

makearray

public java.lang.Object[] makearray(boolean bSupplier,
                                    boolean bRexxStyle)
Modelled after Object Rexx MAKEARRAY method of the array class. This method is executed synchronized.

Parameters:
bSupplier - boolean value to indicate whether a supplier array (containing the appropriate indices as Strings) is to be prepared and returned (if set to true).
bRexxStyle - boolean value to indicate whether using Rexx (index starts at: 1) or Java (index starts at: 0) style for creating the indices for a supplier.
Returns:
a two-dimensional array of Objects, where the first element contains the single dimensioned array and the second element the optional supplier array