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 which is used when we have no value to return 030 * <p> 031 * 032 * @param <K> The type for the Key 033 * @param <V> The type for the stored value 034 * 035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 036 */ 037public class EmptyValueCursor<V> implements ValueCursor<V> 038{ 039 private long revision; 040 private long creationDate; 041 042 /** 043 * Creates a new instance of Cursor, starting on a page at a given position. 044 * 045 * @param transaction The transaction this operation is protected by 046 * @param stack The stack of parent's from root to this page 047 */ 048 public EmptyValueCursor( long revision ) 049 { 050 super(); 051 052 this.revision = revision; 053 creationDate = System.currentTimeMillis(); 054 } 055 056 057 /** 058 * Change the position in the current cursor to set it after the last key 059 */ 060 public void afterLast() throws IOException 061 { 062 } 063 064 065 /** 066 * Change the position in the current cursor before the first key 067 */ 068 public void beforeFirst() throws IOException 069 { 070 } 071 072 073 /** 074 * Tells if the cursor can return a next element 075 * 076 * @return true if there are some more elements 077 * @throws IOException 078 * @throws EndOfFileExceededException 079 */ 080 public boolean hasNext() throws EndOfFileExceededException, IOException 081 { 082 return false; 083 } 084 085 086 /** 087 * Tells if the cursor can return a next key 088 * 089 * @return true if there are some more keys 090 * @throws IOException 091 * @throws EndOfFileExceededException 092 */ 093 public boolean hasNextKey() throws EndOfFileExceededException, IOException 094 { 095 return false; 096 } 097 098 099 /** 100 * Tells if the cursor can return a previous element 101 * 102 * @return true if there are some more elements 103 * @throws IOException 104 * @throws EndOfFileExceededException 105 */ 106 public boolean hasPrev() throws EndOfFileExceededException, IOException 107 { 108 return false; 109 } 110 111 112 /** 113 * Tells if the cursor can return a previous key 114 * 115 * @return true if there are some more keys 116 * @throws IOException 117 * @throws EndOfFileExceededException 118 */ 119 public boolean hasPrevKey() throws EndOfFileExceededException, IOException 120 { 121 return false; 122 } 123 124 125 /** 126 * {@inheritDoc} 127 */ 128 @Override 129 public V prev() throws EndOfFileExceededException, IOException 130 { 131 return null; 132 } 133 134 135 /** 136 * {@inheritDoc} 137 */ 138 @Override 139 public V next() throws EndOfFileExceededException, IOException 140 { 141 return null; 142 } 143 144 145 /** 146 * {@inheritDoc} 147 */ 148 public void close() 149 { 150 } 151 152 153 /** 154 * Get the creation date 155 * @return The creation date for this cursor 156 */ 157 public long getCreationDate() 158 { 159 return creationDate; 160 } 161 162 163 /** 164 * Get the current revision 165 * 166 * @return The revision this cursor is based on 167 */ 168 public long getRevision() 169 { 170 return revision; 171 } 172 173 174 /** 175 * {@inheritDoc} 176 */ 177 @Override 178 public int size() 179 { 180 return 0; 181 } 182 183 184 public String toString() 185 { 186 return "EmptyValueCursor"; 187 } 188}