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.xdbm;
021
022
023 import org.apache.directory.shared.ldap.cursor.Cursor;
024
025
026 /**
027 * A Cursor introducing new advance methods designed to reduce some
028 * inefficiencies encountered when scanning over Tuples.
029 *
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 * @version $$Rev$$
032 */
033 public interface TupleCursor<K, V> extends Cursor<Tuple<K, V>>
034 {
035 /**
036 * An alternative to calling before(Tuple) which often may require
037 * wrapping a key in a newly created Tuple object that may be unnecessary.
038 * This method behaves just like before(Tuple) except it advances to just
039 * before the first value of the key.
040 *
041 * @param key the key to advance just before
042 * @throws Exception if there are faults peforming this operation
043 */
044 void beforeKey( K key ) throws Exception;
045
046
047 /**
048 * An alternative to calling after(Tuple) which often may require
049 * wrapping a key in a newly created Tuple object that may be unnecessary.
050 * This method behaves just like after(Tuple) except it advances to just
051 * after the last value of the key.
052 *
053 * @param key the key to advance just after the last value
054 * @throws Exception if there are faults peforming this operation
055 */
056 void afterKey( K key ) throws Exception;
057
058
059 /**
060 * An alternative to calling before(Tuple) which often may require
061 * wrapping a key and a value in a newly created Tuple object that may be
062 * unnecessary. This method behaves just like before(Tuple) except it
063 * advances to just before the value of the key which may still be of the
064 * same key. This method will not be supported if duplicate keys are not
065 * supported. In this case an UnsupportedOperationException will be
066 * thrown.
067 *
068 * @param key the key of the value to advance just before
069 * @param value the value to advance just before
070 * @throws UnsupportedOperationException if duplicate keys not supporrted
071 * @throws Exception if there are faults peforming this operation
072 */
073 void beforeValue( K key, V value ) throws Exception;
074
075
076 /**
077 * An alternative to calling after(Tuple) which often may require
078 * wrapping a key and a value in a newly created Tuple object that may be
079 * unnecessary. This method behaves just like after(Tuple) except it
080 * advances to just after the value with the specified key. This method
081 * will not be supported if duplicate keys are not supported. In this
082 * case an UnsupportedOperationException will be thrown.
083 *
084 * @param key the key of the value to advance just after
085 * @param value the value to advance just after
086 * @throws UnsupportedOperationException if duplicate keys not supporrted
087 * @throws Exception if there are faults peforming this operation
088 */
089 void afterValue( K key, V value ) throws Exception;
090 }