1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.server.core.partition.impl.btree;
21
22
23 import java.io.Serializable;
24
25 import org.apache.directory.server.schema.SerializableComparator;
26
27
28 /**
29 * Used to compare the sorting order of binary data.
30 *
31 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32 * @version $Rev: 610243 $
33 */
34 public interface TupleComparator<K,V> extends Serializable
35 {
36 /**
37 * Gets the comparator used to compare keys. May be null in which
38 * case the compareKey method will throw an UnsupportedOperationException.
39 *
40 * @return the comparator for comparing keys.
41 */
42 SerializableComparator<K> getKeyComparator();
43
44
45 /**
46 * Gets the binary comparator used to compare valuess. May be null in which
47 * case the compareValue method will throw an UnsupportedOperationException.
48 *
49 * @return the binary comparator for comparing values.
50 */
51 SerializableComparator<V> getValueComparator();
52
53
54 /**
55 * Compares key Object to determine their sorting order returning a
56 * value = to, < or > than 0.
57 *
58 * @param key1 the first key to compare
59 * @param key2 the other key to compare to the first
60 * @return 0 if both are equal, a negative value less than 0 if the first
61 * is less than the second, or a postive value if the first is greater than
62 * the second byte array.
63 */
64 int compareKey( K key1, K key2 );
65
66
67 /**
68 * Comparse value Objects to determine their sorting order returning a
69 * value = to, < or > than 0.
70 *
71 * @param value1 the first value to compare
72 * @param value2 the other value to compare to the first
73 * @return 0 if both are equal, a negative value less than 0 if the first
74 * is less than the second, or a postive value if the first is greater than
75 * the second Object.
76 */
77 int compareValue( V value1, V value2 );
78 }