edu.northwestern.at.utils.swing
Class SortedTableModelRow

java.lang.Object
  extended by edu.northwestern.at.utils.swing.SortedTableModelRow
All Implemented Interfaces:
SortedTableModel.Row

public class SortedTableModelRow
extends java.lang.Object
implements SortedTableModel.Row

Simple concrete implementation of sorted table model row.

Defines a simple concrete implementation of the SortedTableModel.Row interface. The unique row ID may be specified as the value of a column, or as a separate value. The column values may be any objects which implement the Comparable interface.


Field Summary
protected  java.lang.Comparable[] rowData
          The data for this row.
protected  java.lang.Object uniqueID
          The unique row identifier value if not present in the row data.
protected  int uniqueIDColumn
          The column number for the unique row identifier.
 
Constructor Summary
SortedTableModelRow(java.lang.Comparable[] rowData)
          Create a row from an array of objects.
SortedTableModelRow(java.lang.Comparable[] rowData, int uniqueIDColumn)
          Create a row from an array of objects.
SortedTableModelRow(java.lang.Comparable[] rowData, java.lang.Object uniqueID)
          Create a row from an array of objects.
 
Method Summary
 int compareTo(SortedTableModel.Row other, int columnIndex)
          Compare value in specified column with same column in another row.
 java.lang.Object getUniqueRowID()
          Get the unique row identifier.
 java.lang.Object getValue(int columnIndex)
          Get value in specified column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rowData

protected java.lang.Comparable[] rowData
The data for this row.


uniqueIDColumn

protected int uniqueIDColumn
The column number for the unique row identifier. Set negative to use separate uniqueID value.


uniqueID

protected java.lang.Object uniqueID
The unique row identifier value if not present in the row data.

Constructor Detail

SortedTableModelRow

public SortedTableModelRow(java.lang.Comparable[] rowData)
Create a row from an array of objects.

Parameters:
rowData - Array of objects to use as row data. The first entry in the row data is assumed to contain a unique row identifier.

SortedTableModelRow

public SortedTableModelRow(java.lang.Comparable[] rowData,
                           int uniqueIDColumn)
Create a row from an array of objects.

Parameters:
rowData - Array of objects to use as row data. The first entry is assumed to be a unique row identifier.
uniqueIDColumn - Column number of the unique row ID value.

SortedTableModelRow

public SortedTableModelRow(java.lang.Comparable[] rowData,
                           java.lang.Object uniqueID)
Create a row from an array of objects.

Parameters:
rowData - Array of objects to use as row data. The first entry is assumed to be a unique row identifier.
uniqueID - Object containing the unique ID for this row.
Method Detail

getValue

public java.lang.Object getValue(int columnIndex)
Get value in specified column.

Specified by:
getValue in interface SortedTableModel.Row
Parameters:
columnIndex - The column index of the value to return.
Returns:
The data value for the specified column, if the column index is valid, or null if the column index is invalid.

compareTo

public int compareTo(SortedTableModel.Row other,
                     int columnIndex)
Compare value in specified column with same column in another row.

Specified by:
compareTo in interface SortedTableModel.Row
Parameters:
other - The other row.
columnIndex - The index of the column to compare.
Returns:
< 0: this row's value < other row's value = 0: this row's value == other row's value > 0: this row's value > other row's value

getUniqueRowID

public java.lang.Object getUniqueRowID()
Get the unique row identifier.

Specified by:
getUniqueRowID in interface SortedTableModel.Row
Returns:
The unique row identifier.