org.apache.tapestry.contrib.table.model.simple
Class ColumnComparator

java.lang.Object
  extended by org.apache.tapestry.contrib.table.model.simple.ColumnComparator
All Implemented Interfaces:
Comparator

public class ColumnComparator
extends Object
implements Comparator

In order to provide more generic behaviour, ITableColumn has no "column value" concept. The comparator it returns compares two table rows, rather than values specific to the column.

SimpleTableColumn introduces the concept of "column value" and allows one to extract that "column value" from the row using the getColumnValue() method. In practice comparisons are also typically done between these values rather than the full row objects.

This comparator extracts the column values from the rows passed and uses the provided comparator to compare the values. It therefore allows a comparator designed for comparing column values to be quickly wrapped and used as a comparator comparing rows, which is what ITableColumn is expected to return.

Example:

objColumn.setComparator(new ColumnComparator(objColumn, objBeanComparator));

Version:
$Id: ColumnComparator.java 243791 2004-02-19 17:38:13Z hlship $
Author:
mindbridge

Constructor Summary
ColumnComparator(SimpleTableColumn objColumn, Comparator objComparator)
           
 
Method Summary
 int compare(Object objRow1, Object objRow2)
           
 
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

ColumnComparator

public ColumnComparator(SimpleTableColumn objColumn,
                        Comparator objComparator)
Method Detail

compare

public int compare(Object objRow1,
                   Object objRow2)
Specified by:
compare in interface Comparator
See Also:
Comparator.compare(Object, Object)