com.sas.table
Interface StaticTableInterface

All Known Subinterfaces:
ColumnTemplateTableInterface, DataTableInterface, FreeformTableInterface, RowTemplateTableInterface, StaticColumnTemplateTableInterface, StaticRowTemplateTableInterface, TableInterface
All Known Implementing Classes:
JDBCToDataTableAdapter

public interface StaticTableInterface

Defines an interface for accessing two-dimensional data.

Two-dimensional data is commonly referred to as rectangular or tabular data, or simply as "table". Tables are composed of a horizontal dimension -- "the columns" -- and a vertical dimension -- "the rows". The intersection of a column with a row is called a "cell". Some common examples of tables are SAS datasets, ODBC and JDBC databases, two-dimensional arrays, and spreadsheets. Classes which implement StaticTableInterface are known as "table models".

StaticTableInterface defines methods for retrieving the number and class of columns, the number and class of rows, and the class and value of cells. Methods for adding and deleting rows and columns, and modifying cells are left to an extended interface (see TableInterface), hence the inclusion of "static" in the interface name. Methods dealing with additional metadata, including column and row labels, are also left to other interfaces to define.

The data returned by this interface (i.e. getCell()) is assumed to be unformatted or raw data hence the use of the Object class to categorize it. If your table also has formatted data of class String, then also implement StaticFormattedDataInterface.

Most of StaticTableInterface's methods have index parameters. All of these indices are one-based. For example, to get the class of the first column use getColumnClass(1). Array parameters, including returned arrays, use zero-based indexing as usual.

See Also:
StaticFormattedDataInterface, StaticColumnLabelInterface, StaticRowLabelInterface, TableInterface, TableView

Method Summary
 int countColumns(int maxCount)
          Counts the columns.
 int countRows(int maxCount)
          Counts the rows.
 java.lang.Object getCell(int rowIndex, int columnIndex)
          Returns the value of a cell.
 java.lang.Class getCellClass(int rowIndex, int columnIndex)
          Returns the class of a cell.
 java.lang.Class[][] getCellClasses(int startRowIndex, int startColumnIndex, int rowCount, int columnCount)
          Returns the classes for a block of cells.
 java.lang.Object[][] getCells(int startRowIndex, int startColumnIndex, int rowCount, int columnCount)
          Returns the values for a block of cells.
 java.lang.Object[] getColumn(int index)
          Returns the values of all the cells in a column.
 int getColumnCount()
          Returns the number of columns available.
 java.lang.Object[] getRow(int index)
          Returns the values of all the cells in a row.
 int getRowCount()
          Returns the number of rows available.
 

Method Detail

countColumns

int countColumns(int maxCount)
                 throws com.sas.table.TableException
Counts the columns. countColumns() differs from getColumnCount() when the number of columns is unknown, i.e. when getColumnCount() returns -1. If your implementation of getColumnCount() never returns -1, then simply define countColumns() as a return of getColumnCount(), otherwise read-on.

countColumns() is an instruction to determine the number of columns even though that number is not readily known. To limit the potential overhead of this determination, the maximum number of columns to read may be specified.

Parameters:
maxCount - Maximum number of columns to read, or 0 to read indefinitely. Implementations where the number of columns is always known should ignore this parameter. In cases where the total number of columns is unknown, but the number known so far is greater than maxCount should return the larger known number. Thus maxCount is only used as a limiting factor when the implementation has to actually do computation (e.g. fetch observations).
Returns:
The number of columns known to be available.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
See Also:
getColumnCount(), StaticTableInterfaceSupport.countColumns(com.sas.table.StaticTableInterface, int)

countRows

int countRows(int maxCount)
              throws com.sas.table.TableException
Counts the rows. countRows() differs from getRowCount() when the number of rows is unknown, i.e. when getRowCount() returns -1. If your implementation of getRowCount() never returns -1, then simply define countRows() as a return of getRowCount(), otherwise read-on.

countRows() is an instruction to determine the number of rows even though that number is not readily known. To limit the potential overhead of this determination, the maximum number of rows to read may be specified.

Parameters:
maxCount - Maximum number of rows to read, or 0 to read indefinitely. Implementations where the number of rows is always known should ignore this parameter. In cases where the total number of rows is unknown, but the number known so far is greater than maxCount should return the larger known number. Thus maxCount is only used as a limiting factor when the implementation has to actually do computation (e.g. fetch observations).
Returns:
The number of rows known to be available.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
See Also:
getRowCount(), StaticTableInterfaceSupport.countRows(com.sas.table.StaticTableInterface, int)

getCell

java.lang.Object getCell(int rowIndex,
                         int columnIndex)
                         throws com.sas.table.TableException
Returns the value of a cell. The cell is identified by the given row and column indices.

Parameters:
rowIndex - A one-based index that identifies the cell's row.
columnIndex - A one-based index that identifies the cell's column.
Returns:
The specified cell's value.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if rowIndex is negative, zero, or greater than the number of rows. Thrown if columnIndex is negative, zero, or greater than the number of columns.
See Also:
getCells(int, int, int, int), getColumn(int), getRow(int)

getCells

java.lang.Object[][] getCells(int startRowIndex,
                              int startColumnIndex,
                              int rowCount,
                              int columnCount)
                              throws com.sas.table.TableException
Returns the values for a block of cells. The block is identified by the intersection of a range of rows with a range of columns. startRowIndex and rowCount define the start and extent of the row range while startColumnIndex and columnCount define the column range. The set of values is returned as a two-dimensional array, new Object[rowCount][colCount], with values[0][0] containing the value of the cell at (startRowIndex, startColumnIndex).

Parameters:
startRowIndex - A one-based index that identifies the start of the row range.
startColumnIndex - A one-based index that identifies the start of the column range.
rowCount - The number of rows in the row range.
columnCount - The number of columns in the column range.
Returns:
The specified cells' values.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if startRowIndex or rowCount is negative, zero, or greater than the number of rows; except when getRowCount() has returned -1 -- in that case, the implementation should reduce rowCount appropriately and the caller should be prepared for a smaller returned array. Thrown if startColumnIndex or columnCount is negative, zero, or greater than the number of columns; except when getColumnCount() has returned -1 -- in that case, the implementation should reduce columnCount appropriately and the caller should be prepared for a smaller returned array.
See Also:
getCell(int, int), StaticTableInterfaceSupport.getCells(com.sas.table.StaticTableInterface, int, int, int, int)

getCellClass

java.lang.Class getCellClass(int rowIndex,
                             int columnIndex)
                             throws com.sas.table.TableException
Returns the class of a cell. The cell is identified by the given row and column indices.

Parameters:
rowIndex - A one-based index that identifies the cell's row.
columnIndex - A one-based index that identifies the cell's column.
Returns:
The specified cell's class.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if rowIndex is negative, zero, or greater than the number of rows. Thrown if columnIndex is negative, zero, or greater than the number of columns.
See Also:
getCellClasses(int, int, int, int)

getCellClasses

java.lang.Class[][] getCellClasses(int startRowIndex,
                                   int startColumnIndex,
                                   int rowCount,
                                   int columnCount)
                                   throws com.sas.table.TableException
Returns the classes for a block of cells. The block is identified by the intersection of a range of rows with a range of columns. startRowIndex and rowCount define the start and extent of the row range while startColumnIndex and columnCount define the column range. The set of classes is returned as a two-dimensional array, new Class[rowCount][colCount], with clases[0][0] containing the class of the cell at (startRowIndex, startColumnIndex).

Parameters:
startRowIndex - A one-based index that identifies the start of the row range.
startColumnIndex - A one-based index that identifies the start of the column range.
rowCount - The number of rows in the row range.
columnCount - The number of columns in the column range.
Returns:
The specified cells' classes.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if startRowIndex or rowCount is negative, zero, or greater than the number of rows; except when getRowCount() has returned -1 -- in that case, the implementation should reduce rowCount appropriately and the caller should be prepared for a smaller returned array. Thrown if startColumnIndex or columnCount is negative, zero, or greater than the number of columns; except when getColumnCount() has returned -1 -- in that case, the implementation should reduce columnCount appropriately and the caller should be prepared for a smaller returned array.
See Also:
getCellClass(int, int), StaticTableInterfaceSupport.getCellClasses(com.sas.table.StaticTableInterface, int, int, int, int)

getColumn

java.lang.Object[] getColumn(int index)
                             throws com.sas.table.TableException
Returns the values of all the cells in a column. The column is identified by the given index. The set of values is returned as an array with each element of the array corresponding to a cell in the column.

Parameters:
index - A one-based index that identifies the column.
Returns:
The values of the specified column's cells.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if index is negative, zero, or greater than the number of columns.
See Also:
getCell(int, int), StaticTableInterfaceSupport.getColumn(com.sas.table.StaticTableInterface, int)

getColumnCount

int getColumnCount()
                   throws com.sas.table.TableException
Returns the number of columns available. If the number of columns is unknown, -1 should be returned. Note that returning -1 requires the implementation to handle countColumns(), getCells(), and getCellClasses() a little differently; see those methods for more details. Also in the unknown case, the caller should not heedlessly use getRow() since the actual number of columns could be very large.

Returns:
The value of the columnCount property.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
See Also:
countColumns(int)

getRow

java.lang.Object[] getRow(int index)
                          throws com.sas.table.TableException
Returns the values of all the cells in a row. The row is identified by the given index. The set of values is returned as an array with each element of the array corresponding to a cell in the row.

Parameters:
index - A one-based index that identifies the row.
Returns:
The values of the specified row's cells.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
java.lang.IndexOutOfBoundsException - Thrown if index is negative, zero, or greater than the number of rows.
See Also:
getCell(int, int), StaticTableInterfaceSupport.getRow(com.sas.table.StaticTableInterface, int)

getRowCount

int getRowCount()
                throws com.sas.table.TableException
Returns the number of rows available. If the number of rows is unknown, -1 should be returned. Note that returning -1 requires the implementation to handle countRows(), getCells(), and getCellClasses() a little differently; see those methods for more details. Also in the unknown case, the caller should not heedlessly use getColumn() since the actual number of rows could be very large.

Returns:
The value of the rowCount property.
Throws:
TableException - Thrown if the query can not be satisfied (e.g. i/o-failure).
See Also:
countRows(int)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.