com.simba.dsi.dataengine.impl
Class DSISimpleArray

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

public class DSISimpleArray
extends DSIArray

A concrete implementation of DSIArray that is backed by a Java array.


Nested Class Summary
protected  class DSISimpleArray.DSISimpleArrayIterator
          A simple iterator that is backed by an array.
 
Field Summary
protected  java.lang.Object m_array
          The array instance backing the DSISimpleArray.
protected  int m_length
          The cached length of the array.
 
Constructor Summary
DSISimpleArray(java.lang.Object array, IColumn arrayMetadata, IColumn nestedMetadata)
          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  java.util.Iterator<?> createIterator(long offset, int count)
          Creates an Iterator over the element data of the Array.
protected  IColumn getArrayColumn()
          Returns the metadata of the column holding the array.
 IColumn getBaseColumn()
          Returns the metadata that describes the base type of the array.
protected  IColumn getNestedColumn()
          Returns the metadata of the most nested element in the array.
 java.lang.String getStringRepresentation()
          Returns a string representation of the array.
protected  boolean isMultidimensional()
          Returns whether this instance represents a multi-dimensional array.
 
Methods inherited from class com.simba.dsi.dataengine.impl.DSIArray
createResultSet, free, getComponentClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_array

protected java.lang.Object m_array
The array instance backing the DSISimpleArray.


m_length

protected int m_length
The cached length of the array.

Constructor Detail

DSISimpleArray

public DSISimpleArray(java.lang.Object array,
                      IColumn arrayMetadata,
                      IColumn nestedMetadata)
Constructor.

Creates a DSISimpleArray backed by a Java array. The array must be of a type that is supported by the DataWrapper, and multidimensional arrays should be supplied as a multidimensional array of the base type, instead of an array of IArray.

For example, for a VARCHAR[][] column, a non-null String[][] instance should be provided as the array argument.

Parameters:
array - the backing array instance.
arrayMetadata - the metadata of the column which holds this array. This metadata is required if the array is multidimensional.
nestedMetadata - the metadata of the most nested element in the array.
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.

This implementation creates a copy of the backing array for single dimensional arrays, and an array of DSISimpleArray for multidimensional arrays.

Specified by:
createArray in interface IArray
Overrides:
createArray in class DSIArray
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.

getBaseColumn

public 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
Specified by:
getBaseColumn in class DSIArray
Returns:
the metadata that describes the base type of the array.

createIterator

protected 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 DSIArray.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.

Specified by:
createIterator in class DSIArray
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.

getArrayColumn

protected IColumn getArrayColumn()
Returns the metadata of the column holding the array.

Returns:
the metadata of the column holding the array.

getNestedColumn

protected IColumn getNestedColumn()
Returns the metadata of the most nested element in the array.

Returns:
the metadata of the most nested element in the array.

isMultidimensional

protected boolean isMultidimensional()
Returns whether this instance represents a multi-dimensional array.

Returns:
whether this instance represents a multi-dimensional array.

getStringRepresentation

public java.lang.String getStringRepresentation()
Returns a string representation of the array.

Returns:
a string representation of the array.


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