org.apache.directory.shared.ldap.schema
Class ComparableComparator

java.lang.Object
  extended byorg.apache.directory.shared.ldap.schema.ComparableComparator
All Implemented Interfaces:
java.util.Comparator, java.io.Serializable

public class ComparableComparator
extends java.lang.Object
implements java.util.Comparator, java.io.Serializable

Compares two objects taking into account that one might be a Comparable.

Version:
$Rev: 379008 $
Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
ComparableComparator()
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two objects taking into account that one may be a Comparable.
 
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

ComparableComparator

public ComparableComparator()
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two objects taking into account that one may be a Comparable. If the first is a comparable then its compareTo operation is called and the result returned as is. If the first is not a Comparable but the second is then its compareTo method is called and the result is returned after being negated. If none are comparables the hashCode of o1 minus the hashCode of o2 is returned.

Specified by:
compare in interface java.util.Comparator
See Also:
Comparator.compare(Object, Object)


Copyright © 2003-2006 . All Rights Reserved.