quoggles.auxiliary
Class Comparators.TableComparator

java.lang.Object
  |
  +--quoggles.auxiliary.Comparators.TableComparator
All Implemented Interfaces:
java.util.Comparator
Enclosing class:
Comparators

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

Used to compare a table (list of lists) according to the first sortByNr columns.


Field Summary
private  int sortByNr
           
 
Constructor Summary
Comparators.TableComparator(int sortByNr)
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
private  int elemCompare(java.lang.Object el1, java.lang.Object el2)
          Compares two elements according to the natural order.
private  int listCompare(java.util.List l1, java.util.List l2)
          Iterates through the lists (both same size).
 
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
 

Field Detail

sortByNr

private int sortByNr
Constructor Detail

Comparators.TableComparator

public Comparators.TableComparator(int sortByNr)
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)

listCompare

private int listCompare(java.util.List l1,
                        java.util.List l2)
Iterates through the lists (both same size). First element comparison that yields a value other than zero sets the result of this comparison. If all comparisons yield zero, the two lists are considered equal.

Parameters:
l1 -
l2 -
Returns:
according to Comparator interface

elemCompare

private int elemCompare(java.lang.Object el1,
                        java.lang.Object el2)
Compares two elements according to the natural order. If an element does not implement interface Comparable, the toString() method is used.

Parameters:
el1 -
el2 -
Returns:
el1.compareTo(el2)