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