Clover coverage report - Code Coverage for tapestry-contrib release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:42:40 EDT
file stats: LOC: 64   Methods: 2
NCLOC: 18   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ColumnComparator.java - 0% 0% 0%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.contrib.table.model.simple;
 16   
 17    import java.util.Comparator;
 18   
 19    /**
 20    * In order to provide more generic behaviour, ITableColumn
 21    * has no "column value" concept. The comparator it returns
 22    * compares two table rows, rather than values specific to the column.
 23    * <p>
 24    * SimpleTableColumn introduces the concept of "column value" and
 25    * allows one to extract that "column value" from the row using
 26    * the getColumnValue() method. In practice comparisons are also typically
 27    * done between these values rather than the full row objects.
 28    * <p>
 29    * This comparator extracts the column values from the rows passed
 30    * and uses the provided comparator to compare the values.
 31    * It therefore allows a comparator designed for comparing column values to be
 32    * quickly wrapped and used as a comparator comparing rows, which is what
 33    * ITableColumn is expected to return.
 34    * <p>
 35    * Example:
 36    * <p>
 37    * objColumn.setComparator(new ColumnComparator(objColumn, objBeanComparator));
 38    *
 39    * @author mindbridge
 40    *
 41    */
 42    public class ColumnComparator implements Comparator
 43    {
 44    private SimpleTableColumn m_objColumn;
 45    private Comparator m_objComparator;
 46   
 47  0 public ColumnComparator(SimpleTableColumn objColumn, Comparator objComparator)
 48    {
 49  0 m_objColumn = objColumn;
 50  0 m_objComparator = objComparator;
 51    }
 52   
 53    /**
 54    * @see java.util.Comparator#compare(Object, Object)
 55    */
 56  0 public int compare(Object objRow1, Object objRow2)
 57    {
 58  0 Object objValue1 = m_objColumn.getColumnValue(objRow1);
 59  0 Object objValue2 = m_objColumn.getColumnValue(objRow2);
 60   
 61  0 return m_objComparator.compare(objValue1, objValue2);
 62    }
 63   
 64    }