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.mavibot.btree; 021 022 023import java.io.IOException; 024 025import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException; 026 027 028/** 029 * A Cursor is used to fetch elements in a BTree and is returned by the 030 * @see BTree#browse method. The cursor <strng>must</strong> be closed 031 * when the user is done with it. 032 * <p> 033 * 034 * @param <V> The type for the stored value 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public interface ValueCursor<V> extends Cursor<V> 039{ 040 /** 041 * Find the next key/value 042 * 043 * @return A Tuple containing the found key and value 044 * @throws IOException 045 * @throws EndOfFileExceededException 046 */ 047 V next() throws EndOfFileExceededException, IOException; 048 049 050 /** 051 * Find the previous key/value 052 * 053 * @return A Tuple containing the found key and value 054 * @throws IOException 055 * @throws EndOfFileExceededException 056 */ 057 V prev() throws EndOfFileExceededException, IOException; 058 059 060 /** 061 * @return The number of elements stored in the cursor 062 */ 063 int size(); 064}