com.sas.storage.jdbc
Class JDBCColumnValuesAdapter

com.sas.storage.jdbc.JDBCColumnValuesAdapter
All Implemented Interfaces:
com.sas.table.StaticColumnInfoInterface, com.sas.util.transforms.DisplayTransformInterface
Direct Known Subclasses:
JDBCToListModelAdapter, JDBCToTreeModelAdapter

public abstract class JDBCColumnValuesAdapter

The purpose of the JDBCColumnValuesAdapter is to optionally allow multiple JDBC column values from a result set row to be returned as a single Object by JDBC adapters.

If the setRetrieveAllColumnValues property is set to true, then the adapter will get all of the column values for the requested row index in the form of a Map containing the column names (all uppercased) mapped to the column values. If a column values transform has been specified, via the setColumnValuesTransform method, the adapter will use it to trasform the Map values into a single Object, otherwise the Map itself will be returned.

If the setRetrieveAllColumnValues property is set to false, then a single column value is returned. See the documentation in subclasses of the JDBCColumnValuesAdapter for more information about which column value is returned.


Field Summary
protected  com.sas.util.transforms.TransformInterface columnValuesTransform
          Transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object when retrieveAllColumnValues is true
protected  boolean retrieveAllColumnValues
          Indicates if the adapter will retrieve all of the column values for a particular row index in the result set in the form of a Map
 
Fields inherited from class com.sas.storage.jdbc.JDBCAdapter
autoCommit, CLASS_NAME, columnInfoUsed, conn, designTime, displayTransform, forwardOnly, initialized, isRowCountKnown, LABEL, meta, NAME, printWarnings, queryRowCountDisabled, queryStatement, RB_KEY, readOnly, result, resultSetRequeryUsed, resultSetType, resultSetUsed, retrieveNumericTypesAsDouble, rowCount, rowCountQueryString, rowNumber, spcs, stmt, trimUsed
 
Constructor Summary
JDBCColumnValuesAdapter(java.sql.Connection conn, java.lang.String queryStatement)
          Constructor used to create an initialized adapter.
JDBCColumnValuesAdapter(java.sql.ResultSet result)
          Constructor used to connect an adapter directly to a previously created ResultSet.
 
Method Summary
protected  java.util.Map getColumnValuesMap(java.sql.ResultSet resultSet)
          Returns a Map containing the column names (all uppercased) mapped to the column values from the current row in the result set.
 com.sas.util.transforms.TransformInterface getColumnValuesTransform()
          Returns the transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object.
 boolean isRetrieveAllColumnValues()
          if true, indicates the adapter will retrieve all of the column values for a particular row in the result set in the form of a Map, mapping column names (all uppercased) to column values.
protected  java.lang.Object retrieveColumnValueAt(int col, java.sql.ResultSet result)
          Returns the column value from the current row in the specified result set.
protected  java.lang.Object retrieveValueAt(int col, java.sql.ResultSet resultSet)
          If the setRetrieveAllColumnValues property is set to true, then the adapter will get all of the column values at the current cursor position in the result set in the form of a Map, mapping column names (all uppercased) to column values.
 void setColumnValuesTransform(com.sas.util.transforms.TransformInterface transform)
          Sets the transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object.
 void setRetrieveAllColumnValues(boolean value)
          If set to true, the adapter will retrieve all of the column values for a particular row in the result set in the form of a Map, mapping column names (all uppercased) to column values.
 
Methods inherited from class com.sas.storage.jdbc.JDBCAdapter
addPropertyChangeListener, addPropertyChangeListener, calculateRowCount, close, doAbsolute, doCountColumns, doUpdateCell, finalize, fireCellEvent, fireModelEvent, fireModelEvent, getAutoCommit, getColumnInfo, getColumnInfoNames, getConnection, getDisplayTransform, getModel, getPrintWarnings, getQueryStatement, getResultSetConcurrency, getResultSetRowCount, getResultSetType, getRowCountByCountFunction, getRowCountQueryString, init, initializeData, isQueryRowCountDisabled, isReadOnly, isResultSetRequeryUsed, isRetrieveNumericTypesAsDouble, isTrimUsed, printSQLWarning, putColumnInfoUsed, putValueAt, refresh, removePropertyChangeListener, removePropertyChangeListener, retrieveColumnClass, retrieveColumnCount, retrieveColumnIndex, retrieveColumnInfoUsed, retrieveColumnLabel, retrieveRawSASNumericValue, retrieveRawSASNumericValue, retrieveValueAt, setAutoCommit, setConnection, setDisplayTransform, setModel, setPrintWarnings, setQueryRowCountDisabled, setQueryStatement, setReadOnly, setResultSetRequeryUsed, setResultSetType, setRetrieveNumericTypesAsDouble, setRowCountQueryString, setTrimUsed
 

Field Detail

columnValuesTransform

protected com.sas.util.transforms.TransformInterface columnValuesTransform
Transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object when retrieveAllColumnValues is true


retrieveAllColumnValues

protected boolean retrieveAllColumnValues
Indicates if the adapter will retrieve all of the column values for a particular row index in the result set in the form of a Map

Constructor Detail

JDBCColumnValuesAdapter

public JDBCColumnValuesAdapter(java.sql.ResultSet result)
Constructor used to connect an adapter directly to a previously created ResultSet.

Parameters:
result - ResultSet to use.

JDBCColumnValuesAdapter

public JDBCColumnValuesAdapter(java.sql.Connection conn,
                               java.lang.String queryStatement)
Constructor used to create an initialized adapter.

Parameters:
conn - A java.sql.Connection object.
queryStatement - A SQL query that is valid for the database represented by conn.
Method Detail

setRetrieveAllColumnValues

public void setRetrieveAllColumnValues(boolean value)
If set to true, the adapter will retrieve all of the column values for a particular row in the result set in the form of a Map, mapping column names (all uppercased) to column values. If a columnValuesTransform has been specified, the adapter will use it to transform the Map, otherwise the Map itself will be returned. If false, then a single column value is returned as determined by subclasses of this adapter.

Parameters:
value - indicates if the adapter will retrieve all of the column values for a row in the result set in the form of a Map

isRetrieveAllColumnValues

public boolean isRetrieveAllColumnValues()
if true, indicates the adapter will retrieve all of the column values for a particular row in the result set in the form of a Map, mapping column names (all uppercased) to column values. If false, then a single column value is returned as determined by subclasses of this adapter.


setColumnValuesTransform

public void setColumnValuesTransform(com.sas.util.transforms.TransformInterface transform)
Sets the transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object. This transform is only used by the adapter if the setRetrieveAllColumnValues property is set to true.


getColumnValuesTransform

public com.sas.util.transforms.TransformInterface getColumnValuesTransform()
Returns the transform used to transform a Map, containing column names (all uppercased) mapped to column values, to a single Object. This transform is only used by the adapter if the setRetrieveAllColumnValues property is set to true.


retrieveValueAt

protected java.lang.Object retrieveValueAt(int col,
                                           java.sql.ResultSet resultSet)
                                    throws java.sql.SQLException
If the setRetrieveAllColumnValues property is set to true, then the adapter will get all of the column values at the current cursor position in the result set in the form of a Map, mapping column names (all uppercased) to column values. If a columnValuesTransform has been specified, the adapter uses it to transform the Map, otherwise the Map itself is returned.

If the setRetrieveAllColumnValues property is set to false, then the column value at the specified column index is returned from the current cursor position in the result set.

Overrides:
retrieveValueAt in class JDBCAdapter
Parameters:
col - A one-based index that identifies a column in the result set.
resultSet - the ResultSet from which to retrieve the values.
Returns:
an Object based on column values from the current row in the result set.
Throws:
java.sql.SQLException - thrown if ResultSet throws an SQLException.

getColumnValuesMap

protected java.util.Map getColumnValuesMap(java.sql.ResultSet resultSet)
                                    throws java.sql.SQLException
Returns a Map containing the column names (all uppercased) mapped to the column values from the current row in the result set.

Returns:
a Map containing the column names (all uppercased) mapped to the column values from the current row in the result set
Throws:
java.sql.SQLException

retrieveColumnValueAt

protected java.lang.Object retrieveColumnValueAt(int col,
                                                 java.sql.ResultSet result)
                                          throws java.sql.SQLException
Returns the column value from the current row in the specified result set. It calls the ResultSet getXXX method recommended in the JDBC API for the specified column's data type.

Parameters:
col - A one-based index that identifies the result set column.
result - ResultSet from which to get values.
Returns:
The column value from the current row in the specified result set.
Throws:
java.sql.SQLException - thrown if ResultSet throws a SQLException.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.