1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.partition.impl.btree;
18
19
20 import java.io.Serializable;
21
22 import org.apache.ldap.server.schema.SerializableComparator;
23
24
25 /***
26 * A TupleComparator that compares keys only.
27 *
28 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
29 * @version $Rev: 264732 $
30 */
31 public class KeyOnlyComparator
32 implements TupleComparator, Serializable
33 {
34 private static final long serialVersionUID = 3544956549803161397L;
35
36 private SerializableComparator keyComparator = null;
37
38
39 public KeyOnlyComparator( SerializableComparator comparator )
40 {
41 keyComparator = comparator;
42 }
43
44
45 /***
46 * Gets the comparator used to compare keys. May be null in which
47 * case the compareKey method will throw an UnsupportedOperationException.
48 *
49 * @return the comparator for comparing keys.
50 */
51 public SerializableComparator getKeyComparator()
52 {
53 return keyComparator;
54 }
55
56
57 /***
58 * Will throw an UnsupportedOperationException every time.
59 */
60 public SerializableComparator getValueComparator()
61 {
62 throw new UnsupportedOperationException();
63 }
64
65
66 /***
67 * Compares key Object to determine their sorting order returning a
68 * value = to, < or > than 0.
69 *
70 * @param key1 the first key to compare
71 * @param key2 the other key to compare to the first
72 * @return 0 if both are equal, a negative value less than 0 if the first
73 * is less than the second, or a postive value if the first is greater than
74 * the second byte array.
75 */
76 public int compareKey( Object key1, Object key2 )
77 {
78 return keyComparator.compare( key1, key2 );
79 }
80
81
82 /***
83 * Comparse value Objects to determine their sorting order returning a
84 * value = to, < or > than 0.
85 *
86 * @param value1 the first value to compare
87 * @param value2 the other value to compare to the first
88 * @return 0 if both are equal, a negative value less than 0 if the first
89 * is less than the second, or a postive value if the first is greater than
90 * the second Object.
91 */
92 public int compareValue( Object value1, Object value2 )
93 {
94 throw new UnsupportedOperationException();
95 }
96 }