org.apache.directory.server.core.partition.impl.btree
Class KeyOnlyComparator

java.lang.Object
  extended by org.apache.directory.server.core.partition.impl.btree.KeyOnlyComparator
All Implemented Interfaces:
java.io.Serializable, TupleComparator

public class KeyOnlyComparator
extends java.lang.Object
implements TupleComparator, java.io.Serializable

A TupleComparator that compares keys only.

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

Constructor Summary
KeyOnlyComparator(SerializableComparator comparator)
           
 
Method Summary
 int compareKey(java.lang.Object key1, java.lang.Object key2)
          Compares key Object to determine their sorting order returning a value = to, < or > than 0.
 int compareValue(java.lang.Object value1, java.lang.Object value2)
          Comparse value Objects to determine their sorting order returning a value = to, < or > than 0.
 SerializableComparator getKeyComparator()
          Gets the comparator used to compare keys.
 SerializableComparator getValueComparator()
          Will throw an UnsupportedOperationException every time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyOnlyComparator

public KeyOnlyComparator(SerializableComparator comparator)
Method Detail

getKeyComparator

public SerializableComparator getKeyComparator()
Gets the comparator used to compare keys. May be null in which case the compareKey method will throw an UnsupportedOperationException.

Specified by:
getKeyComparator in interface TupleComparator
Returns:
the comparator for comparing keys.

getValueComparator

public SerializableComparator getValueComparator()
Will throw an UnsupportedOperationException every time.

Specified by:
getValueComparator in interface TupleComparator
Returns:
the binary comparator for comparing values.

compareKey

public int compareKey(java.lang.Object key1,
                      java.lang.Object key2)
Compares key Object to determine their sorting order returning a value = to, < or > than 0.

Specified by:
compareKey in interface TupleComparator
Parameters:
key1 - the first key to compare
key2 - the other key to compare to the first
Returns:
0 if both are equal, a negative value less than 0 if the first is less than the second, or a postive value if the first is greater than the second byte array.

compareValue

public int compareValue(java.lang.Object value1,
                        java.lang.Object value2)
Comparse value Objects to determine their sorting order returning a value = to, < or > than 0.

Specified by:
compareValue in interface TupleComparator
Parameters:
value1 - the first value to compare
value2 - the other value to compare to the first
Returns:
0 if both are equal, a negative value less than 0 if the first is less than the second, or a postive value if the first is greater than the second Object.