001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.server.core.partition.impl.btree; 021 022 023 import java.io.Serializable; 024 025 import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; 026 027 028 /** 029 * Used to compare the sorting order of binary data. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 * @version $Rev: 917231 $ 033 */ 034 public interface TupleComparator<K, V> extends Serializable 035 { 036 /** 037 * Gets the comparator used to compare keys. May be null in which 038 * case the compareKey method will throw an UnsupportedOperationException. 039 * 040 * @return the comparator for comparing keys. 041 */ 042 SerializableComparator<K> getKeyComparator(); 043 044 045 /** 046 * Gets the binary comparator used to compare valuess. May be null in which 047 * case the compareValue method will throw an UnsupportedOperationException. 048 * 049 * @return the binary comparator for comparing values. 050 */ 051 SerializableComparator<V> getValueComparator(); 052 053 054 /** 055 * Compares key Object to determine their sorting order returning a 056 * value = to, < or > than 0. 057 * 058 * @param key1 the first key to compare 059 * @param key2 the other key to compare to the first 060 * @return 0 if both are equal, a negative value less than 0 if the first 061 * is less than the second, or a postive value if the first is greater than 062 * the second byte array. 063 */ 064 int compareKey( K key1, K key2 ); 065 066 067 /** 068 * Comparse value Objects to determine their sorting order returning a 069 * value = to, < or > than 0. 070 * 071 * @param value1 the first value to compare 072 * @param value2 the other value to compare to the first 073 * @return 0 if both are equal, a negative value less than 0 if the first 074 * is less than the second, or a postive value if the first is greater than 075 * the second Object. 076 */ 077 int compareValue( V value1, V value2 ); 078 }