com.simba.dsi.dataengine.impl
Class DSIDataEngine

java.lang.Object
  extended by com.simba.dsi.dataengine.impl.DSIDataEngine
All Implemented Interfaces:
IDataEngine

public abstract class DSIDataEngine
extends java.lang.Object
implements IDataEngine

Abstract implementation of DSIDataEngine. Only MakeNewMetadataResult is implemented here and this class's existence is to make creating metadata results easier.


Constructor Summary
protected DSIDataEngine(IStatement statement)
          Constructor.
 
Method Summary
 void close()
          Closes the IDataEngine and releases any resources held by it.
 boolean getIsODBC2()
          Whether we're running under the context of an ODBC 2.X driver.
protected  com.simba.support.ILogger getLog()
          Get the logger to use for this data engine.
protected  IResultSet getMetadataResultImplementation(MetadataSourceID metadataSourceId, java.util.Map<MetadataSourceColumnTag,java.lang.String> restrictions, IMetadataSource metadataSource, java.util.List<IFilter> filters, OrderType orderType)
          Returns a concrete implementation of a metadata result set.
protected  IStatement getParentStatement()
          Get the parent statement of this data engine.
protected  com.simba.support.IWarningListener getWarningListener()
          Gets the warning listener of the parent statement of this data engine.
 IResultSet makeNewMetadataResult(MetadataSourceID metadataSourceId, java.util.ArrayList<java.lang.String> filterValues, java.lang.String escapeChar, java.lang.String identifierQuoteChar, boolean filterAsIdentifier)
          Produces an IResultSet filled with metadata.
 IResultSet makeNewMetadataResult(MetadataSourceID metadataSourceId, java.util.ArrayList<java.lang.String> filterValues, java.lang.String escapeChar, java.lang.String identifierQuoteChar, boolean filterAsIdentifier, OrderType orderType)
          Produces an IResultSet filled with metadata.
protected abstract  IMetadataSource makeNewMetadataSource(MetadataSourceID metadataSourceId, java.util.Map<MetadataSourceColumnTag,java.lang.String> restrictions, java.lang.String escapeChar, java.lang.String identifierQuoteChar, boolean filterAsIdentifier)
          Creates a metadata source which may filter out unneeded rows according to the given restrictions.
abstract  IQueryExecutor prepare(java.lang.String query)
          Produces an IQueryExecutor which can be used to execute the given query.
 IQueryExecutor prepareBatch(java.util.List<java.lang.String> queries)
          Produces an IQueryExecutor which can be used to execute the given batch of queries.
 void setDirectExecute()
          Indicate that any queries prepared by this data engine will be executed immediately, and only once.
 void setMetadataNeeded(boolean isNeeded)
          Indicate whether this data engine will need to create an IQueryExecutor that can return metadata before the execute call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSIDataEngine

protected DSIDataEngine(IStatement statement)
Constructor.

Parameters:
statement - The parent statement of the data engine.
Method Detail

close

public void close()
Closes the IDataEngine and releases any resources held by it.

Specified by:
close in interface IDataEngine

getIsODBC2

public final boolean getIsODBC2()
Whether we're running under the context of an ODBC 2.X driver.


makeNewMetadataResult

public IResultSet makeNewMetadataResult(MetadataSourceID metadataSourceId,
                                        java.util.ArrayList<java.lang.String> filterValues,
                                        java.lang.String escapeChar,
                                        java.lang.String identifierQuoteChar,
                                        boolean filterAsIdentifier)
                                 throws com.simba.support.exceptions.ErrorException
Produces an IResultSet filled with metadata. The result set's columns are determined by the metadata result indicator. The rest of the arguments specify how filtering is to be done for the results provided by the IResultSet.

There is no IQueryExecutor produced for metadata results, just an IResultSet. Internally, the client may convert the metadata request into a SQL query and use an IQueryExecutor to execute, but externally all that's provided is the results.

The IResultSet returned by this call must be non-null. Even if there are no rows, column metadata is still needed.

Specified by:
makeNewMetadataResult in interface IDataEngine
Parameters:
metadataSourceId - Identifies the type of metadata information to be produced.
filterValues - An ArrayList of String values used to filter the columns of the result set. These filters are passed in by the application that calls the catalog function and cannot be modified. For example, the catalog function "SQLTables" contains the arguments "CatalogName", "SchemaName", "TableName", and "TableType". These arguments are extracted to the filterValues String. While these values cannot be modified, if the CatalogName is NULL, the current catalog name is used.
escapeChar - Escape character used in filtering.
identifierQuoteChar - Character used as a quote around identifiers.
filterAsIdentifier - Indicates if string filters are treated as identifiers.
Returns:
IMetadataSource holding the requested metadata results.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

makeNewMetadataResult

public IResultSet makeNewMetadataResult(MetadataSourceID metadataSourceId,
                                        java.util.ArrayList<java.lang.String> filterValues,
                                        java.lang.String escapeChar,
                                        java.lang.String identifierQuoteChar,
                                        boolean filterAsIdentifier,
                                        OrderType orderType)
                                 throws com.simba.support.exceptions.ErrorException
Produces an IResultSet filled with metadata. The result set's columns are determined by the metadata result indicator. The rest of the arguments specify how filtering is to be done for the results provided by the IResultSet.

There is no IQueryExecutor produced for metadata results, just an IResultSet. Internally, the client may convert the metadata request into a SQL query and use an IQueryExecutor to execute, but externally all that's provided is the results.

The IResultSet returned by this call must be non-null. Even if there are no rows, column metadata is still needed.

Specified by:
makeNewMetadataResult in interface IDataEngine
Parameters:
metadataSourceId - Identifies the type of metadata information to be produced.
filterValues - An ArrayList of String values used to filter the columns of the result set.
escapeChar - Escape character used in filtering.
identifierQuoteChar - Character used as a quote around identifiers.
filterAsIdentifier - Indicates if string filters are treated as identifiers.
orderType - The order type to apply.
Returns:
IMetadataSource holding the requested metadata results.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs

prepare

public abstract IQueryExecutor prepare(java.lang.String query)
                                throws ParsingException,
                                       com.simba.support.exceptions.ErrorException
Produces an IQueryExecutor which can be used to execute the given query. The query string is guaranteed to have already been converted into "native SQL" using IConnection.toNativeSQL().

The resultant IQueryExecutor should expose IResult*s for each anticipated result set, including column metadata describing the results if possible.

Specified by:
prepare in interface IDataEngine
Parameters:
query - SQL query, in "native SQL" form.
Returns:
IQueryExecutor which can be used for executing query.
Throws:
ParsingException - If an error occurs in parsing the query.
com.simba.support.exceptions.ErrorException - If any other error occurs.

prepareBatch

public IQueryExecutor prepareBatch(java.util.List<java.lang.String> queries)
                            throws ParsingException,
                                   com.simba.support.exceptions.ErrorException
Produces an IQueryExecutor which can be used to execute the given batch of queries. The query strings are guaranteed to have already been converted into "native SQL" using IConnection.toNativeSQL().

The batch of queries must be queries that return row count results. Queries that return result sets are not allowed to be included in a batch because Statement.executeBatch() can only return an array of row counts and not result sets.

If errors are encountered during batch processing, the IQueryExecutor should create and add IErrorResult objects to the IQueryExecutor's list of results so that they can be used to properly report errors after batch processing.

Specified by:
prepareBatch in interface IDataEngine
Parameters:
queries - SQL queries, in "native SQL" form.
Returns:
IQueryExecutor which can be used for executing the batch of queries.
Throws:
ParsingException - If an error occurs in parsing the query.
com.simba.support.exceptions.ErrorException - If any other error occurs.

setDirectExecute

public void setDirectExecute()
Indicate that any queries prepared by this data engine will be executed immediately, and only once.

If this function is not called, then the prepared query may be executed multiple times.

If not needed, this hint can be safely ignored.

Specified by:
setDirectExecute in interface IDataEngine

setMetadataNeeded

public void setMetadataNeeded(boolean isNeeded)
Indicate whether this data engine will need to create an IQueryExecutor that can return metadata before the execute call.

If this method is not called or called with a true value, the data engine must create an IQueryExecutor that can return metadata at any time after the prepare call. If this method is called with a false value, the data engine can create an IQueryExecutor that only needs to return metadata after the execute call.

If not needed, this hint can be safely ignored.

Specified by:
setMetadataNeeded in interface IDataEngine
Parameters:
isNeeded - Indicates whether this data engine will need to create an IQueryExecutor that can return metadata before the execute call.

getLog

protected com.simba.support.ILogger getLog()
Get the logger to use for this data engine.

Returns:
The logger to use for this data engine.

getParentStatement

protected IStatement getParentStatement()
Get the parent statement of this data engine.

Returns:
The parent statement of this data engine.

getWarningListener

protected com.simba.support.IWarningListener getWarningListener()
Gets the warning listener of the parent statement of this data engine.

Returns:
The warning listener of the parent statement of this data engine.

makeNewMetadataSource

protected abstract IMetadataSource makeNewMetadataSource(MetadataSourceID metadataSourceId,
                                                         java.util.Map<MetadataSourceColumnTag,java.lang.String> restrictions,
                                                         java.lang.String escapeChar,
                                                         java.lang.String identifierQuoteChar,
                                                         boolean filterAsIdentifier)
                                                  throws com.simba.support.exceptions.ErrorException
Creates a metadata source which may filter out unneeded rows according to the given restrictions.

Parameters:
metadataSourceId - Identifier to create the appropriate metadata source.
restrictions - The restrictions to be applied to the metadata table. Only columns that have restrictions appear in the collection of restrictions. Some restrictions may not be passed to the DSII if there are wildcards. The wildcards are '_' for a single character and '%' for multiple characters. These are not passed down to avoid problems with filtering the wildcards literally, and are instead handled by the SDK. Note that if you wish to have full filtering, please refer to DSI_FILTER_METADATA_SOURCE.
escapeChar - Escape character used in filtering.
identifierQuoteChar - Character used as a quote around identifiers.
filterAsIdentifier - Indicates if string filters are treated as identifiers.
Returns:
An IMetadataSource object representing the requested metadata.
Throws:
com.simba.support.exceptions.ErrorException - If an error occurs.

getMetadataResultImplementation

protected IResultSet getMetadataResultImplementation(MetadataSourceID metadataSourceId,
                                                     java.util.Map<MetadataSourceColumnTag,java.lang.String> restrictions,
                                                     IMetadataSource metadataSource,
                                                     java.util.List<IFilter> filters,
                                                     OrderType orderType)
                                              throws com.simba.support.exceptions.ErrorException
Returns a concrete implementation of a metadata result set.

This basic implementation returns a new instance of DSIMetadataResultSet.

Parameters:
metadataSourceId - Identifier to create the appropriate metadata source.
restrictions - Restrictions to be applied to the metadata table. Only columns that have restrictions appear in the collection of restrictions.
metadataSource - Metadata source that contains the raw data.
filters - A list of metadata filters used to determine which rows are needed in retrieving data.
orderType - The order type to apply.
Returns:
An IResutSet that has a concrete implementation of the metadata result.
Throws:
com.simba.support.exceptions.ErrorException - If the metadata source ID is invalid.


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