javax.infobus
Interface ArrayAccess

All Known Subinterfaces:
ReshapeableArrayAccess

public abstract interface ArrayAccess

DataItems that implement the ArrayAccess interface are collections of DataItems organized in an n-dimensional array. The ArrayAccess interface contains methods to determine dimensions, obtain individual elements of the data set, to iterate over all elements in the data set, and to subdivide one ArrayAccess object into another ArrayAccess.


Method Summary
 int[] getDimensions()
          Returns an array of integers which has the same number of elements as the number of dimensions in the ArrayAccess and where each integer value is the the number of elements in the respective ArrayAccess dimension.
 java.lang.Object getItemByCoordinates(int[] coordinates)
          Returns the DataItem corresponding to the given coordinates.
 void setItemByCoordinates(int[] coordinates, java.lang.Object newValue)
          Sets a new value for an item at the indicated coordinates in an ArrayAccess.
 ArrayAccess subdivide(int[] startCoordinates, int[] endCoordinates)
          Returns a subset ArrayAccess of this ArrayAccess.
 

Method Detail

getItemByCoordinates

public java.lang.Object getItemByCoordinates(int[] coordinates)
Returns the DataItem corresponding to the given coordinates. Valid coordinates for dimension k are 0 to (getDimensions()[k] - 1).
Parameters:
coordinates - the coordinates of the desired DataItem in array form
Returns:
the DataItem located at the given coordinates
Throws:
ArrayIndexOutOfBoundsException - if any of coordinates[k] are less than 0 or greater than getDimensions()[k] - 1

setItemByCoordinates

public void setItemByCoordinates(int[] coordinates,
                                 java.lang.Object newValue)
                          throws InvalidDataException
Sets a new value for an item at the indicated coordinates in an ArrayAccess. Setting a data item via this method should not affect Iterators for other access interfaces on the object that implements ArrayAccess. Indexing in each dimension is zero-based; that is, coordinates[i] range from 0 to (getDimensions()[i] - 1 ), to agree with Java arrays. We recommend that all producers accept an ImmediateAccess, if present, as the source of a new value, but also allow for producers to accept other types of Objects that make sense for the application.
Parameters:
coordinates - the coordinates of the element to set
newValue - the new value of the element
Throws:
InvalidDataException - if changes are supported but newValue is not a legal value for the element
UnsupportedOperationException - if changes are not supported

subdivide

public ArrayAccess subdivide(int[] startCoordinates,
                             int[] endCoordinates)
Returns a subset ArrayAccess of this ArrayAccess. For each dimension k, endCoordinates[k] must be greater than or equal to startCoordinates[k]. The indexes of the returned ArrayAccess are readjusted to be zero-based.
Parameters:
startCoordinates - the coordinates in the original ArrayAccess of the first item in the desired subset
endCoordinates - the coordinates in the original ArrayAccess of the last item in the desired subset
Returns:
a subset ArrayAccess defined by startCoordinates and endCoordinates
Throws:
ArrayIndexOutOfBoundsException - if any of startCoordinates[k] or endCoordinates[k] are less than 0 or greater than getDimensions()[k] - 1, or if endCoordinates[k] is less than startCoordinates[k]

getDimensions

public int[] getDimensions()
Returns an array of integers which has the same number of elements as the number of dimensions in the ArrayAccess and where each integer value is the the number of elements in the respective ArrayAccess dimension. For example, a return value of {5,6,7} indicates a 5 x 6 x 7 three-dimensional ArrayAccess.
Returns:
array of dimension sizes