edu.jhu.tmaj.client.tables.data
Class TableComparator

java.lang.Object
  extended by edu.jhu.tmaj.client.tables.data.TableComparator
All Implemented Interfaces:
java.util.Comparator

public final class TableComparator
extends java.lang.Object
implements java.util.Comparator

A Comparator that is used to sort rows in a JTable. This comparator could be used like: Collections.sort(dataList, new TableComparator(columnNumber)); The variable dataList represents a List of Lists representing the data in the table, such that every List represents one row. This is the Comparator that sorts the data in SortFilterFrame. The Comparator attempts to convert the values in table cells to integers and then sort by the natural ordering of integers; if this can not be done, it sorts according to the natural ordering of strings. The sorting is case insensitive.


Constructor Summary
TableComparator(int columnToSort)
          Constructs this object.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

TableComparator

public TableComparator(int columnToSort)
Constructs this object.

Parameters:
columnToSort - the column number in the JTable the user wants to sort
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - a List representing a row in the JTable
o2 - a List representing another row in the JTable
Returns:
a negative integer if the first row should come before the second row (See Comparable Interface)