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