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