org.jboss.cache.optimistic
Class FqnComparator

java.lang.Object
  extended by org.jboss.cache.optimistic.FqnComparator
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator

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

Compares the order of two FQN. Sorts by name, then by depth, e.g.

 aaa/bbb
 xxx
 xxx/ccc 
 

Author:
Manik Surtani (manik@jboss.org), Steve Woodcock (stevew@jofti.com)
See Also:
Serialized Form

Field Summary
static FqnComparator INSTANCE
           
 
Constructor Summary
FqnComparator()
          Sorts by name, then depth.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Returns -1 if the first comes before; 0 if they are the same; 1 if the second Fqn comes before.
protected  int compareElements(java.lang.Object e1, java.lang.Object e2)
          Compares two Fqn elements.
 
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

INSTANCE

public static final FqnComparator INSTANCE
Constructor Detail

FqnComparator

public FqnComparator()
Sorts by name, then depth.

Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Returns -1 if the first comes before; 0 if they are the same; 1 if the second Fqn comes before. null always comes first.

Specified by:
compare in interface java.util.Comparator

compareElements

protected int compareElements(java.lang.Object e1,
                              java.lang.Object e2)
Compares two Fqn elements. If e1 and e2 are the same class and e1 implements Comparable, returns e1.compareTo(e2). Otherwise, returns e1.toString().compareTo(e2.toString()).



Copyright 1998-2005 JBoss Inc . All Rights Reserved.