com.simba.dsi.dataengine.impl
Class DSIArray

java.lang.Object
  extended by com.simba.dsi.dataengine.impl.DSIArray
All Implemented Interfaces:
IArray
Direct Known Subclasses:
DSISimpleArray

public abstract class DSIArray
extends java.lang.Object
implements IArray

Abstract implementation of IArray.


Constructor Summary
protected DSIArray()
          Constructor.
 
Method Summary
 java.lang.Object createArray(long offset, int count)
          Creates either a subtype of Object[] or a primitive array (such as int[]), representing the materialized values of this IArray.
protected abstract  java.util.Iterator<?> createIterator(long offset, int count)
          Creates an Iterator over the element data of the Array.
 IResultSet createResultSet(long offset, int count)
          Creates an IResult representing the contents of this IArray.
 void free()
          Frees resources consumed by the IArray.
abstract  IColumn getBaseColumn()
          Returns the metadata that describes the base type of the array.
protected  java.lang.Class<?> getComponentClass()
          Returns the component type of the Array created by createArray(long, int).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.simba.dsi.dataengine.interfaces.IArray
getStringRepresentation
 

Constructor Detail

DSIArray

protected DSIArray()
Constructor.

Method Detail

createArray

public java.lang.Object createArray(long offset,
                                    int count)
                             throws com.simba.support.exceptions.ErrorException
Creates either a subtype of Object[] or a primitive array (such as int[]), representing the materialized values of this IArray. The type of the array shall be a correct Java array type that corresponds to the base type of the IArray.

If the IArray represents a multi-dimensional SQL ARRAY, then a Java array which subclasses IArray[] should be returned, instead of a multi-dimensional Java array. For example, String[][] should not be returned.

For the default implementation of this method, createIterator(long, int) has the requirement that the elements returned by the iterator are of the same Java type as the JDBC Type to Java Object Type mapping defined in Table B-3 of the JDBC specification, or of the custom mapping defined for this connection, if the type is a non-Array type.

The component type of the createdArray is specified with the getComponentClass() method, and is assumed to be a type belonging to the type mapping for the Connection that created this Array.

Specified by:
createArray in interface IArray
Parameters:
offset - The offset into the IArray, where a 0 offset corresponds to the startof the IArray.
count - The number of successive elements to fetch, or IResultSet.RETRIEVE_ALL_DATA if all of the elements be fetched.
Returns:
a Java array representing the materialized values of the IArray.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

createResultSet

public IResultSet createResultSet(long offset,
                                  int count)
Creates an IResult representing the contents of this IArray.

Each row of the IResult has two columns. The first column is the index of the data in the IArray, where 1 corresponds to the first element of the IArray, and increases by 1 for each successive row. The second column contains the data elements of this IArray, and if, the IArray is of a single dimension, its metadata is described by the getBaseColumn() call of this IArray.

If the IArray is multidimensional, then the type of the VALUE column of the ResultSet returned by this method should be java.sql.Types.ARRAY.

Specified by:
createResultSet in interface IArray
Parameters:
offset - The offset into the IArray, where a 0 offset corresponds to the start of the IArray.
count - The number of successive elements to fetch, or IResultSet.RETRIEVE_ALL_DATA if all of the elements should be fetched.
Returns:
an IResult containing the data elements of this IArray, with at most count rows if (count != IResultSet.RETRIEVE_ALL_DATA).

free

public void free()
Frees resources consumed by the IArray.

If a subclass overrides this method, then it should call super.free().

Specified by:
free in interface IArray

getBaseColumn

public abstract IColumn getBaseColumn()
Returns the metadata that describes the base type of the array.

If the array is multidimensional, then metadata with the type Types.ARRAY should be returned.

Specified by:
getBaseColumn in interface IArray
Returns:
the metadata that describes the base type of the array.

createIterator

protected abstract java.util.Iterator<?> createIterator(long offset,
                                                        int count)
Creates an Iterator over the element data of the Array. The Objects returned from the iterator shall be of an appropriate Java type for the contained elements of this DSIArray, as defined by the DataWrapper class. If this DSIArray represents a multidimensional array, then it should return an iterator over elements of type IArray.

The elements of the iterator must be accepted by the DataWrapper class for the base type reported by this DSIArray. If the createArray(long, int) method of DSIArray is not overridden, there is an additional requirement that the iterator returns elements of the Java type specified by the JDBC Type to Java Object Type mapping (Table B-3 of the JDBC specification), or by the custom mapping defined for this connection.

For supported JDBC types and specific custom types, this is the type returned by the default implementation of the getComponentClass() method of this class.

After free() is called on this DSIArray instance, the iterator is is not required to produce element data.

Parameters:
offset - the index into the data of the Array. The first element is at offset 0.
count - the number of successive elements to retrieve, or IArray.RETRIEVE_ALL_DATA if all of the data should be retrieved.
Returns:
an iterator over the data, starting at the given index and extending for at most count items.

getComponentClass

protected java.lang.Class<?> getComponentClass()
Returns the component type of the Array created by createArray(long, int).

The createIterator method of this instance must return Objects that are assignable to the returned type.

The default implementation returns the Java type specified by the JDBC Type to Java Object Type mapping defined in Table B-3 of the JDBC specification for supported types, with the exception of IArray for Types.ARRAY.

Returns:
the component type of the Array corresponding to the base type of the DSIArray, or Object.class if the type is unrecognized.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.