org.erif.util
Class SimpleCompare

java.lang.Object
  |
  +--org.erif.util.SimpleCompare
All Implemented Interfaces:
java.util.Comparator

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

For the sorting of objects by the results of a given method Usage: pass in to Array.sort(). i.e.:

 MyClass myarray = MyClass.getValidEntries();
 SimpleCompare myClassFirstNameSort = new SimpleCompare(MyClass.class,"getFirstName",SimpleCompare.ASCENDING);
 Arrays.sort(myarray,myClassFirstNameSort);

Author:
Kaolin Fire Stockinger

Field Summary
static boolean ASCENDING
           
static boolean DESCENDING
           
 
Constructor Summary
SimpleCompare(java.lang.Class c, java.lang.String methodname, boolean direction)
           
SimpleCompare(java.lang.Class c, java.lang.String methodname, boolean direction, java.lang.String methodname2, boolean direction2)
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 int compare(java.lang.Object o1, java.lang.Object o2, java.lang.reflect.Method m, boolean direction)
           
 
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

ASCENDING

public static final boolean ASCENDING

DESCENDING

public static final boolean DESCENDING
Constructor Detail

SimpleCompare

public SimpleCompare(java.lang.Class c,
                     java.lang.String methodname,
                     boolean direction)
              throws java.lang.NoSuchMethodException

SimpleCompare

public SimpleCompare(java.lang.Class c,
                     java.lang.String methodname,
                     boolean direction,
                     java.lang.String methodname2,
                     boolean direction2)
              throws java.lang.NoSuchMethodException
Method Detail

compare

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

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2,
                   java.lang.reflect.Method m,
                   boolean direction)


Copyright © 2003 - kaolin fire