gov.usda.gdpc.util
Class AbstractTable

java.lang.Object
  extended bygov.usda.gdpc.util.AbstractTable
All Implemented Interfaces:
Table
Direct Known Subclasses:
EmptyTable, GenotypeTable, PhenotypeTable

public abstract class AbstractTable
extends java.lang.Object
implements Table

This class provides a skeletal implementation of the Table interface to minimize the effort required to implement this interface.

Author:
terryc

Constructor Summary
AbstractTable()
           
AbstractTable(java.util.List columnHeadings, java.util.List rowHeadings, java.lang.Object[][] data)
          AbstractTable constructor.
 
Method Summary
 java.lang.Object get(int columnIndex, int rowIndex)
          Get the data associated with the specified indices.
 java.lang.Object get(java.lang.Object columnHeading, java.lang.Object rowHeading)
          Get the data associated with specified column heading and row heading.
 java.lang.Object[] getColumn(int columnIndex)
          Get the column for the given column index.
 java.lang.Object[] getColumn(java.lang.Object columnHeading)
          Get the column for the given column heading.
 java.lang.Object getColumnHeading(int index)
          Get the column heading at specified index.
 java.lang.Object[] getColumnHeadings()
          Get column headings for this table.
 java.lang.Object[] getRow(int rowIndex)
          Get the row for the given row index.
 java.lang.Object[] getRow(java.lang.Object rowHeading)
          Get the row for the given row heading.
 java.lang.Object getRowHeading(int index)
          Get row heading at specified index.
 java.lang.Object[] getRowHeadings()
          Get row headings for this table.
 int numColumns()
          Returns number of columns in this table.
 int numRows()
          Returns number of rows in this table.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTable

public AbstractTable()

AbstractTable

public AbstractTable(java.util.List columnHeadings,
                     java.util.List rowHeadings,
                     java.lang.Object[][] data)
AbstractTable constructor.

Parameters:
columnHeadings - list of column headings for this table.
rowHeadings - list of row headings for this table.
data - this table's data
Method Detail

get

public java.lang.Object get(java.lang.Object columnHeading,
                            java.lang.Object rowHeading)
Get the data associated with specified column heading and row heading.

Specified by:
get in interface Table
Parameters:
columnHeading - column heading
rowHeading - row heading
Returns:
data. null if not found.

getRow

public java.lang.Object[] getRow(java.lang.Object rowHeading)
Get the row for the given row heading.

Specified by:
getRow in interface Table
Parameters:
rowHeading - row heading
Returns:
data. null if not found.

getColumn

public java.lang.Object[] getColumn(java.lang.Object columnHeading)
Get the column for the given column heading.

Specified by:
getColumn in interface Table
Parameters:
columnHeading - column heading
Returns:
data. null if not found.

getRow

public java.lang.Object[] getRow(int rowIndex)
Get the row for the given row index.

Specified by:
getRow in interface Table
Parameters:
rowIndex - row index
Returns:
data. null if not found.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (rowIndex < 0 || rowIndex >= numRows()).

getColumn

public java.lang.Object[] getColumn(int columnIndex)
Get the column for the given column index.

Specified by:
getColumn in interface Table
Parameters:
columnIndex - column index
Returns:
data. null if not found.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (columnIndex < 0 || columnIndex >= numColumns()).

get

public final java.lang.Object get(int columnIndex,
                                  int rowIndex)
Get the data associated with the specified indices. Indices start with zero.

Specified by:
get in interface Table
Parameters:
columnIndex - column index
rowIndex - row index
Returns:
data.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (columnIndex < 0 || columnIndex >= numColumns()) or (rowIndex < 0 || rowIndex >= numRows()).

numColumns

public final int numColumns()
Returns number of columns in this table.

Specified by:
numColumns in interface Table
Returns:
number of columns

numRows

public final int numRows()
Returns number of rows in this table.

Specified by:
numRows in interface Table
Returns:
number of rows

toString

public java.lang.String toString()

getColumnHeading

public java.lang.Object getColumnHeading(int index)
Get the column heading at specified index.

Specified by:
getColumnHeading in interface Table
Parameters:
index - column index
Returns:
column heading
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= numColumns()).

getColumnHeadings

public java.lang.Object[] getColumnHeadings()
Get column headings for this table.

Specified by:
getColumnHeadings in interface Table
Returns:
column headings

getRowHeading

public java.lang.Object getRowHeading(int index)
Get row heading at specified index.

Specified by:
getRowHeading in interface Table
Parameters:
index - row index
Returns:
row heading
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= numRows()).

getRowHeadings

public java.lang.Object[] getRowHeadings()
Get row headings for this table.

Specified by:
getRowHeadings in interface Table
Returns:
row headings