com.simba.dsi.dataengine.impl
Class DSIMetadataResultSet

java.lang.Object
  extended by com.simba.dsi.dataengine.impl.DSISimpleResultSet
      extended by com.simba.dsi.dataengine.impl.DSIMetadataResultSet
All Implemented Interfaces:
IResultSet

public class DSIMetadataResultSet
extends DSISimpleResultSet

Implementation of IResultSet that supports only forward only cursors, and filters supplied metadata sources.


Nested Class Summary
protected static class DSIMetadataResultSet.MetadataRow
          Class describing a row.
 
Field Summary
protected  java.util.List<MetadataColumn> m_columns
          The collection of columns for this result set.
protected  boolean m_isODBC2
          Whether this driver is being used as an ODBC 2.X driver.
protected  com.simba.support.ILogger m_logger
          The logger to use for this result.
protected  OrderType m_orderType
          The order type to apply.
protected  java.util.List<DSIMetadataResultSet.MetadataRow> m_rows
          Rows.
protected  java.util.List<MetadataSourceColumnTag> m_sortOrder
          The sort order to apply on the resultSet.
 
Fields inherited from interface com.simba.dsi.dataengine.interfaces.IResultSet
CURSOR_POSITION_BEFORE, RETRIEVE_ALL_DATA, ROW_COUNT_UNKNOWN
 
Constructor Summary
  DSIMetadataResultSet(IStatement statement, MetadataSourceID metadataSourceId, IMetadataSource metadataSource, java.util.List<IFilter> filters, OrderType orderType)
          Constructor.
  DSIMetadataResultSet(IStatement statement, MetadataSourceID metadataSourceId, IMetadataSource metadataSource, java.util.List<IFilter> filters, OrderType orderType, boolean isODBC2)
          Constructor.
protected DSIMetadataResultSet(IStatement statement, MetadataSourceID metadataSourceId, java.util.List<IFilter> filters, OrderType orderType)
          Constructor.
protected DSIMetadataResultSet(IStatement statement, MetadataSourceID metadataSourceId, java.util.List<IFilter> filters, OrderType orderType, boolean isODBC2)
          Constructor.
 
Method Summary
protected  void doCloseCursor()
          Clean up memory by closing the cursor.
protected  boolean doMoveToNextRow()
          Moves the result set's internal cursor to the next row.
 boolean getData(int column, long offset, long maxSize, DataWrapper retrievedData)
          Fills in retrievedData with the corresponding chunk of data.
 long getRowCount()
          Returns the number of rows in the result set.
 java.util.ArrayList<? extends IColumn> getSelectColumns()
          Returns an ArrayList of ColumnMetadatas, corresponding to the columns for which data is provided in the result set.
 java.util.List<MetadataSourceColumnTag> getSortOrder()
          Returns the sort order to apply to the result set data.
protected  boolean getUnsortedData(int column, long offset, long maxSize, DataWrapper retrievedData)
          Fills in retrievedData with the corresponding chunk of data.
 boolean hasMoreRows()
          Returns true if the ResultSet has more rows to fetch.
 boolean hasRowCount()
          Returns true if the ResultSet has a known row count.
protected  void initializeRows()
           
protected  boolean moveToNextUnsortedRow()
          Moves the result set's internal cursor to the next row.
protected  void sortData()
          Gets and sorts all data using the given sort order.
 
Methods inherited from class com.simba.dsi.dataengine.impl.DSISimpleResultSet
appendRow, close, closeCursor, deleteRow, getCurrentRow, getDataNeeded, getFetchSize, getWarningListener, moveToNextRow, onFinishRowUpdate, onStartRowUpdate, registerWarningListener, rowDeleted, rowInserted, rowUpdated, setCursorType, setDataNeeded, setFetchSize, supportsHasMoreRows, writeData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_logger

protected com.simba.support.ILogger m_logger
The logger to use for this result.


m_columns

protected java.util.List<MetadataColumn> m_columns
The collection of columns for this result set.


m_sortOrder

protected java.util.List<MetadataSourceColumnTag> m_sortOrder
The sort order to apply on the resultSet.


m_rows

protected java.util.List<DSIMetadataResultSet.MetadataRow> m_rows
Rows.


m_orderType

protected final OrderType m_orderType
The order type to apply.


m_isODBC2

protected final boolean m_isODBC2
Whether this driver is being used as an ODBC 2.X driver.

Constructor Detail

DSIMetadataResultSet

public DSIMetadataResultSet(IStatement statement,
                            MetadataSourceID metadataSourceId,
                            IMetadataSource metadataSource,
                            java.util.List<IFilter> filters,
                            OrderType orderType)
                     throws com.simba.support.exceptions.ErrorException
Constructor.

Parameters:
statement - The parent statement of the metadata result.
metadataSourceId - The ID of the given metadata source.
metadataSource - The metadata source to retrieve data from.
filters - The filters to use on the metadata source.
orderType - The order type to apply.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

DSIMetadataResultSet

public DSIMetadataResultSet(IStatement statement,
                            MetadataSourceID metadataSourceId,
                            IMetadataSource metadataSource,
                            java.util.List<IFilter> filters,
                            OrderType orderType,
                            boolean isODBC2)
                     throws com.simba.support.exceptions.ErrorException
Constructor.

Parameters:
statement - The parent statement of the metadata result.
metadataSourceId - The ID of the given metadata source.
metadataSource - The metadata source to retrieve data from. Cannot be null.
filters - The filters to use on the metadata source.
orderType - The order type to apply.
isODBC2 - Whether this driver is being used as an ODBC 2.X driver.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

DSIMetadataResultSet

protected DSIMetadataResultSet(IStatement statement,
                               MetadataSourceID metadataSourceId,
                               java.util.List<IFilter> filters,
                               OrderType orderType)
                        throws com.simba.support.exceptions.ErrorException
Constructor.

Parameters:
statement - The parent statement of the metadata result.
metadataSourceId - The ID of the given metadata source.
filters - The filters to use on the metadata source.
orderType - The order type to apply.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

DSIMetadataResultSet

protected DSIMetadataResultSet(IStatement statement,
                               MetadataSourceID metadataSourceId,
                               java.util.List<IFilter> filters,
                               OrderType orderType,
                               boolean isODBC2)
                        throws com.simba.support.exceptions.ErrorException
Constructor.

Parameters:
statement - The parent statement of the metadata result.
metadataSourceId - The ID of the given metadata source.
filters - The filters to use on the metadata source.
orderType - The order type to apply.
isODBC2 - Whether this driver is being used as an ODBC 2.X driver.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.
Method Detail

getData

public boolean getData(int column,
                       long offset,
                       long maxSize,
                       DataWrapper retrievedData)
                throws com.simba.support.exceptions.ErrorException
Fills in retrievedData with the corresponding chunk of data. retrievedData is an uninitialized DataWrapper, and must be modified by this call.

Data is requested from column for the row that the internal cursor is currently positioned at. Column is given as a 0-based index, matching the index of the corresponding column metadata in the ArrayList returned by getSelectColumns().

For character and binary data types, offset is used to indicate an offset within the data cell from which to begin the retrieved chunk. maxSize is used to indicate the suggested maximum size of the retrieved data chunk. offset and maxSize are both given in bytes, and should have no effect when retrieving fixed-width data. The value RETRIEVE_ALL_DATA may be provided as maxSize to indicate that all available data is to be retrieved.

The return value indicates if there is more data left in the current cell. The return value should always be false when retrieving data of a fixed-width type.

If the driver attribute DSI_RETRIEVE_DATA_ORDER_RESTRICTION is set to DSI_RETRIEVE_DATA_IN_NONDECREASING_ORDER, data will only be requested from a row in non-decreasing column order. Data within a single cell will always be requested in increasing offset order, with no chunk overlap.

When requesting chunks of character and binary data, maxSize will typically match the chunk size specified in the DSI_MAXIMUM_RETRIEVE_DATA_CHUNK_SIZE driver attribute when it isn't set to RETRIEVE_ALL_DATA.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Parameters:
column - 0-based column index.
offset - Data offset in bytes.
maxSize - Suggested data chunk size in bytes, or RETRIEVE_ALL_DATA.
retrievedData - Holder for retrieved data.
Returns:
true if there is more data in the current cell; false if there is not.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs
See Also:
DataWrapper

getRowCount

public long getRowCount()
                 throws com.simba.support.exceptions.ErrorException
Returns the number of rows in the result set. The value returned is undefined if the row count is unknown, in which case hasRowCount() should return false.

The value returned must fit into a 32-bit integer when targeting a 32-bit platform, or a 64-bit integer for a 64-bit platform. The value must be non-negative, except if the row count is unknown.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Returns:
Number of rows in the result set.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

getSelectColumns

public java.util.ArrayList<? extends IColumn> getSelectColumns()
                                                        throws com.simba.support.exceptions.ErrorException
Returns an ArrayList of ColumnMetadatas, corresponding to the columns for which data is provided in the result set. Even if there are no rows in the result set, the column metadata should still be accurate. Position in the ArrayList should match position in the result set. The first column should be found at position 0, the second at 1, and so on.

Returns:
An ArrayList of ColumnMetadatas describing the columns in the result set.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

getSortOrder

public java.util.List<MetadataSourceColumnTag> getSortOrder()
                                                     throws com.simba.support.exceptions.ErrorException
Returns the sort order to apply to the result set data.

Returns:
the sort order to apply on the result set content.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

hasMoreRows

public boolean hasMoreRows()
                    throws com.simba.support.exceptions.ErrorException
Returns true if the ResultSet has more rows to fetch. Returns false if there are no more rows to fetch.

Returns:
true if there are more rows to fetch, false otherwise.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

hasRowCount

public boolean hasRowCount()
Returns true if the ResultSet has a known row count. Returns false if the number of rows in the result set is unknown.

Returns:
true if the number of rows is known, false otherwise.

doCloseCursor

protected void doCloseCursor()
                      throws com.simba.support.exceptions.ErrorException
Clean up memory by closing the cursor. Called from closeCursor() to ensure that the ResultSet performs any special handling needed to clear associated memory.

Specified by:
doCloseCursor in class DSISimpleResultSet
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

doMoveToNextRow

protected boolean doMoveToNextRow()
                           throws com.simba.support.exceptions.ErrorException
Moves the result set's internal cursor to the next row. Initially, the cursor should be placed before the first row, so the first call to moveToNextRow() moves it to the first row.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Specified by:
doMoveToNextRow in class DSISimpleResultSet
Returns:
true if the move was successful, false if there is not another row left to move to.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

getUnsortedData

protected boolean getUnsortedData(int column,
                                  long offset,
                                  long maxSize,
                                  DataWrapper retrievedData)
                           throws com.simba.support.exceptions.ErrorException
Fills in retrievedData with the corresponding chunk of data. retrievedData is an uninitialized DataWrapper, and must be modified by this call.

Data is requested from column for the row that the internal cursor is currently positioned at. Column is given as a 0-based index, matching the index of the corresponding column metadata in the ArrayList returned by getSelectColumns().

For character and binary data types, offset is used to indicate an offset within the data cell from which to begin the retrieved chunk. maxSize is used to indicate the suggested maximum size of the retrieved data chunk. offset and maxSize are both given in bytes, and should have no effect when retrieving fixed-width data. The value RETRIEVE_ALL_DATA may be provided as maxSize to indicate that all available data is to be retrieved.

The return value indicates if there is more data left in the current cell. The return value should always be false when retrieving data of a fixed-width type.

If the driver attribute DSI_RETRIEVE_DATA_ORDER_RESTRICTION is set to DSI_RETRIEVE_DATA_IN_NONDECREASING_ORDER, data will only be requested from a row in non-decreasing column order. Data within a single cell will always be requested in increasing offset order, with no chunk overlap.

When requesting chunks of character and binary data, maxSize will typically match the chunk size specified in the DSI_MAXIMUM_RETRIEVE_DATA_CHUNK_SIZE driver attribute when it isn't set to RETRIEVE_ALL_DATA.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Parameters:
column - 0-based column index.
offset - Data offset in bytes.
maxSize - Suggested data chunk size in bytes, or RETRIEVE_ALL_DATA.
retrievedData - Holder for retrieved data.
Returns:
true if there is more data in the current cell; false if there is not.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

initializeRows

protected void initializeRows()
                       throws com.simba.support.exceptions.ErrorException
Throws:
com.simba.support.exceptions.ErrorException

moveToNextUnsortedRow

protected boolean moveToNextUnsortedRow()
                                 throws com.simba.support.exceptions.ErrorException
Moves the result set's internal cursor to the next row. Initially, the cursor should be placed before the first row, so the first call to moveToNextRow() moves it to the first row. The return value indicates if the move was successful or not.

This method will not be called until IQueryExecutor.execute() has been called on the corresponding IQueryExecutor.

Returns:
true if the move was successful, false if there is not another row left to move to.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

sortData

protected void sortData()
                 throws com.simba.support.exceptions.ErrorException
Gets and sorts all data using the given sort order.

Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.


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