com.generationjava.compare
Class ObjectComparator

java.lang.Object
  |
  +--com.generationjava.compare.ObjectComparator
All Implemented Interfaces:
java.util.Comparator

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

Attempts to compare any Object. Some standard types of objects can be dealt with immediately, but others will need a Comparator being added with the static registerComparator method. The following are already handled: Any extension of Comparable. This includes all the Number's and String, Character amongst others. java.net.URL is handled.


Constructor Summary
ObjectComparator()
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
static java.util.Comparator getComparator(java.lang.Class clss)
          Get the Comparator to be used for a particular Class.
static void registerComparator(java.lang.Class clss, java.util.Comparator c)
          Register a Comparator to be used to compare a particular Class.
 
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

ObjectComparator

public ObjectComparator()
Method Detail

registerComparator

public static void registerComparator(java.lang.Class clss,
                                      java.util.Comparator c)
Register a Comparator to be used to compare a particular Class.


getComparator

public static java.util.Comparator getComparator(java.lang.Class clss)
Get the Comparator to be used for a particular Class. If no Comparator is available, then it will search the inheritence tree for one.


compare

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


Copyright © 2000-2003 OSJava. All Rights Reserved.