com.sas.storage.jdbc
Class JDBCToTableModelAdapter

com.sas.storage.jdbc.JDBCToTableModelAdapter
All Implemented Interfaces:
RawSASNumericValueProvider, AccurateRowCountInterface, DeleteRowInterface, com.sas.table.FormattedInterface, InsertRowInterface, com.sas.table.SortableInterface, com.sas.table.StaticColumnInfoInterface, TrueRowCountCalculatedInterface, UpdateRowInterface, com.sas.util.SortDirectionInterface, com.sas.util.transforms.DisplayTransformInterface, javax.swing.table.TableModel

public class JDBCToTableModelAdapter
implements javax.swing.table.TableModel, DeleteRowInterface, UpdateRowInterface, InsertRowInterface, TrueRowCountCalculatedInterface, com.sas.table.SortableInterface, com.sas.table.FormattedInterface, RawSASNumericValueProvider

The JDBCToTableModelAdapter allows JDBC data sources to be displayed in any viewer that requires a model of type javax.swing.table.TableModel, mainly being a javax.swing.JTable.

The adapter requires a java.sql.Connection object and a query statement. They can be passed in on the constructor or set via methods. The setConnection() method will apply the connection object. The setQueryStatement() method will apply the SQL query statement. When non-null values for both connection and query statement have been applied, the adapter is initialized and ready to use.

The query statement must be a SQL query that is valid for the JDBC data source. This may include a blank statement, if valid.

This adapter works best with JDBC drivers that can create scrollable result sets. Table viewers usually need to read backwards to support scrolling the viewer. However, this adapter can support using scrolling viewers with forward-only result sets (ResultSet.TYPE_FORWARD_ONLY). That is accomplished by requerying the result set whenever there is a need to read a row before the current row. There is a performance penalty for this because the server must be requeried and the adapter re-initializes. If you want to turn off this feature, call setResultSetRequeryUsed(false).

Here an example of how the adapter can be created using the JdbcOdbc driver.

 Connection conn = null;
   try
          {
           Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
           conn = java.sql.DriverManager.getConnection("jdbc:odbc:Northwind");
           //create the query statement.
           String queryStatement ="select * from orders";

           //create the Adapter
           JDBCTotableModelAdapter adapter = new JDBCToTableModelAdapter(conn, queryStatement);
          }
 

You can edit your JDBC data with the JDBCToTableModelAdapter if the JDBC driver you are using supports updatable result sets. To do this set the readOnly property on the JDBCToTableModelAdapter to true. Some drivers have specific syntax requirements on the query statement in order to produce updatable result sets. Check your JDBC driver documentaion for details. Please note that if the JDBC driver used does not support updatable results sets, or your query statement is not using the proper syntax to produce an updatable result set, then the result set produced by the driver and used by the JDBCToTableModelAdapter will be read only. Attempts to update a read only result set with the setValueAt method will throw an IllegalStateException.

Sorting your data can be achieved with the sort method. This method will add an order by clause with the specified column names onto the query statement and reinitialize to obtain a sorted result set. If your query statement already contains an order by clause then it is considered pre-sorted and attempting to re-sort with the sort method may fail.

It is possible to lose editing capabilities after applying a sort. This is because some JDBC drivers don't allow sorting and editing to function together. Some drivers may create virtual views which are not editable to support the order by clause, or the syntax of the query statement with the added order by clause cannot produce an updatable result set. In these cases it will be necessary to clear the sort before editing the data. Please check your JDBC driver documentation for details.

The adapter can be configured and used within a webAF project. Add a com.sas.storage.jdbc.JDBCConnection component to your project. Open the customizer and specify the values needed for your JDBC connection.These include driver name and URL. Now open the customizer for the adapter. Specify the value for JDBC Connection using the top combo box. The drop-down list will show all JDBC Connection objects that exist in your project. You can set the properties for query statement, column information used, autoCommit, and read-only, as well.


Field Summary
protected  java.util.Locale formatLocale
          The Locale to use when formatting values.
protected  boolean formattedDataUsed
          Indicates if data returned is formatted.
protected  javax.swing.event.EventListenerList listenerList
          List of listeners
protected  com.sas.util.transforms.ObjectToStringTransform objectToStringTransform
           
static java.lang.String RB_KEY
           
protected  boolean requeryOnNonVisibleChanges
          Indicates if the result set should be reinitialized if changes made are not visible in the result set.
protected  boolean retrievingFormattedData
           
protected  boolean sortAllowed
          Indicates whether sorting is allowed.
 
Fields inherited from class com.sas.storage.jdbc.JDBCRowCountAdapter
currentMaxRowCount, maxRowsFound, READ_AHEAD_AMOUNT, readAheadAmount, trueRowCountCalculated
 
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, readOnly, result, resultSetRequeryUsed, resultSetType, resultSetUsed, retrieveNumericTypesAsDouble, rowCount, rowCountQueryString, rowNumber, spcs, stmt, trimUsed
 
Fields inherited from interface com.sas.table.InsertRowInterface
DEFAULT_INDEX
 
Fields inherited from interface com.sas.util.SortDirectionInterface
ASCENDING, DESCENDING, NOT_SORTED
 
Constructor Summary
JDBCToTableModelAdapter()
          Default constructor called when the adapter is made in a webAF project.
JDBCToTableModelAdapter(java.sql.Connection conn, java.lang.String queryStatement)
          Constructor used to create an initialized adapter.
JDBCToTableModelAdapter(java.sql.ResultSet result)
          Constructor used to connect an adapter directly to a previously created ResultSet.
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
          Adds a listener to the list that is notified each time a change to the data model occurs.
 void cancelUncommittedRow()
          Removes the "fake" row from the model, effectively performing a cancel.
 void commitUncommittedRow()
          Commits the data in the row to the underlying model.
 void deleteRow(int index)
          Deletes a row.
 void fireCellEvent(int row, int column)
          Fire a specific event for a model signaling that one cell has changed.
 void fireModelEvent()
          Fire a default event for a model signaling the some aspect of the model has changed.
 void fireModelEvent(java.util.EventObject event)
          Fire a specific event for a model signaling that some aspect of the model has changed.
protected  void fireModelInsertEvent(int startRow, int endRow)
          Fire a insert event for a model signaling that an insert has occurred.
 java.lang.Class getColumnClass(int col)
          Returns the most specific superclass for all the cell values in the column.
 int getColumnCount()
          Returns the number of columns in the model.
 java.lang.String getColumnInfoUsed()
          Returns the column information that is currently being used as the column label.
 java.lang.String getColumnName(int index)
          Returns the name of the column at columnIndex.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 java.lang.String getFormat(int columnIndex)
          Returns the value from the ResultSetMetaData getColumnTypeName method.
 java.util.Locale getFormatLocale()
          Returns the Locale to format values when the formattedDataUsed property is set to true.
 java.lang.String getFormattedValueAt(int rowIndex, int columnIndex)
          Returns the formatted data for the given cell coordinates.
 java.lang.Double getRawSASNumericValue(int rowIndex, int columnIndex)
          Return the raw value of a numeric cell in the result set.
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.String[] getSortedColumns()
          Returns an array of string that are the column names that have been sorted.
 int[] getSortedDirections()
          Returns an array of ints that indicate which direction each column in the sortedColumns array has been sorted.
 int getUncommittedRowNumber()
          Returns the index of the "fake" row.
 java.lang.Class getUnformattedColumnClass(int col)
          Returns the type of raw data that exists in the given column.
 java.lang.Object getUnformattedValueAt(int rowIndex, int columnIndex)
          Returns the unformatted data for the given cell coordinates.
 java.lang.Object getValueAt(int row, int col)
          Returns the value for the cell at columnIndex and rowIndex.
 void insertUncommittedRow(int row)
          Adds a "fake" row to the table model at the specified location.
 boolean isAccurateRowCountAvailable()
          Returns a boolean value indicating if the row count returned by the getRowCount method is accurate.
 boolean isCellEditable(int row, int col)
          Returns true if the cell at rowIndex and columnIndex is editable.
 boolean isColumnSortable(java.lang.String columnName)
          Returns a boolean indicating whether the columnName is allowed to be sorted.
 boolean isFormattedDataUsed()
          Returns whether the adapter is returning formatted data or the raw data.
 boolean isRequeryOnNonVisibleChanges()
          Returns a value indicating if the result set should be reinitialized when non-visible changes are made to the result set.
 boolean isRowDeletionAllowed()
          Indicates whether rows can be deleted.
 boolean isRowInsertionAllowed()
          Indicates whether rows can be inserted into the existing table.
 boolean isRowUpdateAllowed()
          Indicates whether rows can be updated.
 boolean isSortAllowed()
          Returns a boolean indicating whether sorting is allowed.
 boolean isSortColumnNamesQuoted()
           
 boolean isTableExtendOnly()
          Indicates whether rows can only be inserted at the default location (usually at the end) of the existing table.
 boolean isUncommittedRowPresent()
          Returns true if the "fake" row exists.
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          Removes a listener from the list that is notified each time a change to the data model occurs.
protected  java.lang.Object retrieveValueAt(int col, java.sql.ResultSet result)
          Returns value of a cell in the JDBC data type of the cell.
 void setColumnInfoUsed(java.lang.String info)
          Sets the column information that is currently being used as the column label.
 void setFormatLocale(java.util.Locale locale)
          Sets the Locale to format values when the formattedDataUsed property is set to true.
 void setFormattedDataUsed(boolean useFormattedData)
          Sets whether the adapter returns formatted data or the raw data.
 void setQueryStatement(java.lang.String queryStatement)
          The queryStatement should be any SQL query that is valid for the JDBC data source.
 void setRequeryOnNonVisibleChanges(boolean requeryOnNonVisibleChanges)
          The ability for a ResultSet object to detect insertions and deletions is driver dependant.
 void setSortAllowed(boolean sortAllowed)
          Sets whether sorting is allowed.
 void setSortColumnNamesQuoted(boolean isQuoted)
           
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to value.
 void sort(java.lang.String[] columnNames, int[] direction)
          This method will add an order by clause with the specified column names onto the query statement and reinitialize to obtain a sorted result set.
 
Methods inherited from class com.sas.storage.jdbc.JDBCRowCountAdapter
calculateCurrentMaxRowCount, getReadAheadAmount, isTrueRowCountCalculated, setConnection, setReadAheadAmount, setTrueRowCountCalculated
 
Methods inherited from class com.sas.storage.jdbc.JDBCAdapter
addPropertyChangeListener, addPropertyChangeListener, calculateRowCount, close, doAbsolute, doCountColumns, doUpdateCell, finalize, 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, setDisplayTransform, setModel, setPrintWarnings, setQueryRowCountDisabled, setReadOnly, setResultSetRequeryUsed, setResultSetType, setRetrieveNumericTypesAsDouble, setRowCountQueryString, setTrimUsed
 
Methods inherited from interface com.sas.table.TrueRowCountCalculatedInterface
isTrueRowCountCalculated, setTrueRowCountCalculated
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

listenerList

protected javax.swing.event.EventListenerList listenerList
List of listeners


requeryOnNonVisibleChanges

protected boolean requeryOnNonVisibleChanges
Indicates if the result set should be reinitialized if changes made are not visible in the result set.


formatLocale

protected java.util.Locale formatLocale
The Locale to use when formatting values. Used when the formattedDataUsed property is set to true


objectToStringTransform

protected com.sas.util.transforms.ObjectToStringTransform objectToStringTransform

formattedDataUsed

protected boolean formattedDataUsed
Indicates if data returned is formatted.


sortAllowed

protected boolean sortAllowed
Indicates whether sorting is allowed.


retrievingFormattedData

protected boolean retrievingFormattedData
Constructor Detail

JDBCToTableModelAdapter

public JDBCToTableModelAdapter()
Default constructor called when the adapter is made in a webAF project.


JDBCToTableModelAdapter

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

Parameters:
result - ResultSet to use.

JDBCToTableModelAdapter

public JDBCToTableModelAdapter(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

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Adds a listener to the list that is notified each time a change to the data model occurs.

Specified by:
addTableModelListener in interface javax.swing.table.TableModel
Parameters:
l - The TableModelListener

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Removes a listener from the list that is notified each time a change to the data model occurs.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Parameters:
l - The TableModelListener

setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to value. Throws an IllegalStateException if the result set is not updatable.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Parameters:
value - The new value
rowIndex - The row whose value is to be changed
columnIndex - The column whose value is to be changed
Throws:
java.lang.IllegalStateException - if the result set is not updatable

getColumnName

public java.lang.String getColumnName(int index)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note: this name does not need to be unique; two columns in a table can have the same name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
index - The index of the column
Returns:
the name of the column

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. A JTable uses this method to determine how many columns it should create and display by default.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
The number of columns in the model

getColumnClass

public java.lang.Class getColumnClass(int col)
Returns the most specific superclass for all the cell values in the column. This is used by the JTable to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Parameters:
col - The index of the column
Returns:
The common ancestor class of the object values in the model.

getUnformattedColumnClass

public java.lang.Class getUnformattedColumnClass(int col)
Returns the type of raw data that exists in the given column. This could be used for justifying data left or right in a table even when all formatted data is being displayed.

Specified by:
getUnformattedColumnClass in interface com.sas.table.FormattedInterface
Parameters:
columnIndex - the column whose raw data type is being queried
Returns:
the class type for the raw data of the given column, if the class is unknown, Object.class should probably be returned.

getRowCount

public int getRowCount()
Returns the number of rows in the model. A JTable uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
The number of rows in the model

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Parameters:
row - The row whose value to be queried
col - The column whose value to be queried
Returns:
True if the cell is editable

getColumnInfoUsed

public java.lang.String getColumnInfoUsed()
Returns the column information that is currently being used as the column label. The method will return either NAME or LABEL if the field has been set.

Returns:
The type of information used as the column header.

setColumnInfoUsed

public void setColumnInfoUsed(java.lang.String info)
Sets the column information that is currently being used as the column label. Valid values are "name" and "label". They are not case-sensitive.

Parameters:
info - The type of information to use in column labels.

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

fireCellEvent

public void fireCellEvent(int row,
                          int column)
Fire a specific event for a model signaling that one cell has changed. Subclasses must override this method to fire specific events for their model.

Specified by:
fireCellEvent in class JDBCAdapter
Parameters:
row - row number of the cell that has been modified
column - column number of the cell that has been modified

fireModelEvent

public void fireModelEvent(java.util.EventObject event)
Fire a specific event for a model signaling that some aspect of the model has changed. Subclasses must override this method to fire specific events for their model.

Specified by:
fireModelEvent in class JDBCAdapter
Parameters:
event - Event that must be cast that should be fired

fireModelEvent

public void fireModelEvent()
Fire a default event for a model signaling the some aspect of the model has changed. Subclasses must override this method to fire a default events for their model.

Specified by:
fireModelEvent in class JDBCAdapter

fireModelInsertEvent

protected void fireModelInsertEvent(int startRow,
                                    int endRow)
Description copied from class: JDBCRowCountAdapter
Fire a insert event for a model signaling that an insert has occurred. Subclasses must override this method to fire a default events for their model.

Specified by:
fireModelInsertEvent in class JDBCRowCountAdapter

deleteRow

public void deleteRow(int index)
               throws com.sas.util.UncheckedException
Deletes a row. The row is identified by the given index.

Some implementations may not allow rows to be deleted. This can be determined through isRowDeletionAllowed().

Specified by:
deleteRow in interface DeleteRowInterface
Parameters:
index - A zero-based index that identifies the row.
Throws:
com.sas.util.UncheckedException - Provides a catch-all for all Exceptions.

isRowDeletionAllowed

public boolean isRowDeletionAllowed()
Indicates whether rows can be deleted.

Specified by:
isRowDeletionAllowed in interface DeleteRowInterface
Returns:
true if rows can be deleted, false otherwise.

isRequeryOnNonVisibleChanges

public boolean isRequeryOnNonVisibleChanges()
Returns a value indicating if the result set should be reinitialized when non-visible changes are made to the result set.


setRequeryOnNonVisibleChanges

public void setRequeryOnNonVisibleChanges(boolean requeryOnNonVisibleChanges)
The ability for a ResultSet object to detect insertions and deletions is driver dependant. If set to true, the result set will be reinitialized if changes made to the result set are not visible, thus allowing allowing the changes to be seen. If set to false, the result set will not be reinitialized and non-visible changes will not be seen. The default value is true.

Setting this property to true only affects adapters created with a Connection and a query statement. It will have no affect if the adapter was instantiated with a ResultSet.

The resultSetRequeryUsed property must also be true for reinitialization to occur.

Parameters:
requeryOnNonVisibleChanges - indicates if the result set should be reinitialized when non-visible changes are made

isAccurateRowCountAvailable

public boolean isAccurateRowCountAvailable()
Returns a boolean value indicating if the row count returned by the getRowCount method is accurate.

Specified by:
isAccurateRowCountAvailable in interface AccurateRowCountInterface
Returns:
true if an accurate row count is available, false otherwise.

isRowUpdateAllowed

public boolean isRowUpdateAllowed()
Indicates whether rows can be updated.

Specified by:
isRowUpdateAllowed in interface UpdateRowInterface
Returns:
True if rows can be updated, false otherwise.

insertUncommittedRow

public void insertUncommittedRow(int row)
Description copied from interface: InsertRowInterface
Adds a "fake" row to the table model at the specified location.

Specified by:
insertUncommittedRow in interface InsertRowInterface
Parameters:
row - The row to add the "fake" row before.

commitUncommittedRow

public void commitUncommittedRow()
Description copied from interface: InsertRowInterface
Commits the data in the row to the underlying model.

Specified by:
commitUncommittedRow in interface InsertRowInterface

cancelUncommittedRow

public void cancelUncommittedRow()
Description copied from interface: InsertRowInterface
Removes the "fake" row from the model, effectively performing a cancel.

Specified by:
cancelUncommittedRow in interface InsertRowInterface

isRowInsertionAllowed

public boolean isRowInsertionAllowed()
Description copied from interface: InsertRowInterface
Indicates whether rows can be inserted into the existing table.

Specified by:
isRowInsertionAllowed in interface InsertRowInterface
Returns:
true if new rows can be inserted, false otherwise.

isTableExtendOnly

public boolean isTableExtendOnly()
Description copied from interface: InsertRowInterface
Indicates whether rows can only be inserted at the default location (usually at the end) of the existing table.

Specified by:
isTableExtendOnly in interface InsertRowInterface
Returns:
true if isRowInsertionAllowed is true and the table is only allowed to be extended.

getUncommittedRowNumber

public int getUncommittedRowNumber()
Description copied from interface: InsertRowInterface
Returns the index of the "fake" row. Returns -1 if no "fake" row is present.

Specified by:
getUncommittedRowNumber in interface InsertRowInterface
Returns:
the index of the "fake" row

isUncommittedRowPresent

public boolean isUncommittedRowPresent()
Description copied from interface: InsertRowInterface
Returns true if the "fake" row exists. Once the row is committed or cancelled then the uncommittedRowPresent is false.

Specified by:
isUncommittedRowPresent in interface InsertRowInterface
Returns:
true if an uncommitted row exists

setQueryStatement

public void setQueryStatement(java.lang.String queryStatement)
The queryStatement should be any SQL query that is valid for the JDBC data source. It is used to extract the desired data from the database.

Calling this method has no affect if the constructer taking a ResultSet was used to create the adapter and the ResultSet is not a RowSet.

Overrides:
setQueryStatement in class JDBCRowCountAdapter
Parameters:
queryStatement - The SQL query to apply.

isSortColumnNamesQuoted

public boolean isSortColumnNamesQuoted()

setSortColumnNamesQuoted

public void setSortColumnNamesQuoted(boolean isQuoted)

sort

public void sort(java.lang.String[] columnNames,
                 int[] direction)
          throws com.sas.table.SortException
This method will add an order by clause with the specified column names onto the query statement and reinitialize to obtain a sorted result set. If the original query statement already contains an order by clause then it is considered pre-sorted and attempting to sort with this method may throw a SortException.

Each columnName must have a matching direction. If not, then a SortException will be thrown.

Specified by:
sort in interface com.sas.table.SortableInterface
Parameters:
columnNames - The names of the columns in the order that the columns will be sorted.
direction - The direction in which to sort the columns. Valid values are SortDirectionInterface.ASCENDING and SortDirectionInterface.DESCENDING.
Throws:
com.sas.table.SortException

isColumnSortable

public boolean isColumnSortable(java.lang.String columnName)
Returns a boolean indicating whether the columnName is allowed to be sorted. Sorting is not allowed when the adapter has been instantiated with a ResultSet. The default is that all columns are allowed to be sorted when the adapter is used with a java.sql.Connection.

Specified by:
isColumnSortable in interface com.sas.table.SortableInterface
Parameters:
columnName - The name of the column to query about whether it is allowed to be sorted.
Returns:
A boolean indicating whether the column is allowed to be sorted.

isSortAllowed

public boolean isSortAllowed()
Returns a boolean indicating whether sorting is allowed. Sorting is allowed by default. Sorting is not allowed when the adapter was instantiated with a ResultSet.

Specified by:
isSortAllowed in interface com.sas.table.SortableInterface
Returns:
A boolean indicating whether sorting is allowed.

setSortAllowed

public void setSortAllowed(boolean sortAllowed)
Sets whether sorting is allowed. Sorting is not allowed if the adapter is instantiated with a ResultSet. In that case, setting the sortAllowed property to true will have no affect.

Specified by:
setSortAllowed in interface com.sas.table.SortableInterface
Parameters:
allowed - true if sorting is allowed.

getSortedColumns

public java.lang.String[] getSortedColumns()
Returns an array of string that are the column names that have been sorted. The sortedColumns array is updated after each call to the sort method. The length of the array can be from 0 to the number of available columns. An array of length 0 means that no columns are currently sorted.

Specified by:
getSortedColumns in interface com.sas.table.SortableInterface
Returns:
An array of strings that are the column names on which the data is sorted.

getSortedDirections

public int[] getSortedDirections()
Returns an array of ints that indicate which direction each column in the sortedColumns array has been sorted. The array will be the same size of the sortedColumns array. The sortedDirections array is updated after each call to the sort method.

Specified by:
getSortedDirections in interface com.sas.table.SortableInterface
Returns:
An array of ints that indicate which direction the sorted columns have been sorted. Valid values are com.sas.util.SortDirectionInterface.ASCENDING or com.sas.util.SortDirectionInterface.DESCENDING.

getFormat

public java.lang.String getFormat(int columnIndex)
Returns the value from the ResultSetMetaData getColumnTypeName method. This value is the SAS format that is being used for the given column in the model if the ShareNet or SAS IOM JDBC drivers are being used. An empty string("") is returned if the ResultSetMetaData is null.

Specified by:
getFormat in interface com.sas.table.FormattedInterface
Parameters:
columnIndex - the column index in the model that the format is to be returned for
Returns:
the format that is applied to the raw data, or an empty string("") if no formats are defined for the column.

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
row - The row whose value is to be queried
col - The column whose value is to be queried
Returns:
The value Object at the specified cell

getFormattedValueAt

public java.lang.String getFormattedValueAt(int rowIndex,
                                            int columnIndex)
Returns the formatted data for the given cell coordinates.

Specified by:
getFormattedValueAt in interface com.sas.table.FormattedInterface
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the formatted value of the data at the specified cell

getUnformattedValueAt

public java.lang.Object getUnformattedValueAt(int rowIndex,
                                              int columnIndex)
Returns the unformatted data for the given cell coordinates. In the case where unformatted data is not available and the result set contains only formatted data, then the formatted data is returned.

Specified by:
getUnformattedValueAt in interface com.sas.table.FormattedInterface
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the unformatted value of the data at the specified cell, or the formatted data if unformatted data is not available

retrieveValueAt

protected java.lang.Object retrieveValueAt(int col,
                                           java.sql.ResultSet result)
                                    throws java.sql.SQLException
Description copied from class: JDBCAdapter
Returns value of a cell in the JDBC data type of the cell. It calls the ResultSet getXXX method recommended in the JDBC API for that data type. The cell is identified by the column index of the current row.

Overrides:
retrieveValueAt in class JDBCAdapter
Parameters:
col - A one-based index that identifies the cell's column.
result - ResultSet in which to get values.
Returns:
The specified cell's value.
Throws:
java.sql.SQLException - Thrown if ResultSet throws a SQLException.

setFormattedDataUsed

public void setFormattedDataUsed(boolean useFormattedData)
Sets whether the adapter returns formatted data or the raw data.

Specified by:
setFormattedDataUsed in interface com.sas.table.FormattedInterface
Parameters:
useFormattedData - whether to use formatted data by default versus raw data
See Also:
isFormattedDataUsed()

isFormattedDataUsed

public boolean isFormattedDataUsed()
Returns whether the adapter is returning formatted data or the raw data.

Specified by:
isFormattedDataUsed in interface com.sas.table.FormattedInterface
Returns:
true if formatted data is being used or false otherwise
See Also:
setFormattedDataUsed(boolean)

setFormatLocale

public void setFormatLocale(java.util.Locale locale)
Sets the Locale to format values when the formattedDataUsed property is set to true. If null, or no Locale has been specified then the default locale is used.


getFormatLocale

public java.util.Locale getFormatLocale()
Returns the Locale to format values when the formattedDataUsed property is set to true. The default formatLocale used for formatting is the default locale.

Returns:
the Locale used to format values when the formattedDataUsed property is set to true

getRawSASNumericValue

public java.lang.Double getRawSASNumericValue(int rowIndex,
                                              int columnIndex)
Description copied from interface: RawSASNumericValueProvider
Return the raw value of a numeric cell in the result set.

Specified by:
getRawSASNumericValue in interface RawSASNumericValueProvider
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the raw SAS numeric value. Double.NaN in case of errors or for missing values.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.