ahc.util
Class VarDirectionComparator

java.lang.Object
  |
  +--ahc.util.VarDirectionComparator
All Implemented Interfaces:
java.util.Comparator

public class VarDirectionComparator
extends java.lang.Object
implements java.util.Comparator

This class provides a decorator for another Comparator that allows inverting the direction of the resulting sorting.

For example, a normal Collator provides lexical ordering (placing 'a' before 'b' etc.). Using this decorator class, it becomes possible to switch between this normal ordering and its inverse (placing 'b' before 'a').

This class is particularly useful in the context of user interfaces where the user may want to control the sort order of a table interactively.

Author:
Arno Haase

Constructor Summary
VarDirectionComparator(java.util.Comparator inner)
           
VarDirectionComparator(java.util.Comparator inner, boolean dirInverted)
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 boolean isDirInverted()
           
 void setDirInverted(boolean dirInverted)
           
 void toggleDirection()
           
 
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

VarDirectionComparator

public VarDirectionComparator(java.util.Comparator inner)

VarDirectionComparator

public VarDirectionComparator(java.util.Comparator inner,
                              boolean dirInverted)
Method Detail

compare

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

isDirInverted

public boolean isDirInverted()

setDirInverted

public void setDirInverted(boolean dirInverted)

toggleDirection

public void toggleDirection()