1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.mavibot.btree;
21
22
23 import java.io.IOException;
24
25 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
26
27
28 /**
29 * A Cursor which is used when we have no value to return
30 * <p>
31 *
32 * @param <K> The type for the Key
33 * @param <V> The type for the stored value
34 *
35 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
36 */
37 public class EmptyValueCursor<V> implements ValueCursor<V>
38 {
39 private long revision;
40 private long creationDate;
41
42 /**
43 * Creates a new instance of Cursor, starting on a page at a given position.
44 *
45 * @param transaction The transaction this operation is protected by
46 * @param stack The stack of parent's from root to this page
47 */
48 public EmptyValueCursor( long revision )
49 {
50 super();
51
52 this.revision = revision;
53 creationDate = System.currentTimeMillis();
54 }
55
56
57 /**
58 * Change the position in the current cursor to set it after the last key
59 */
60 public void afterLast() throws IOException
61 {
62 }
63
64
65 /**
66 * Change the position in the current cursor before the first key
67 */
68 public void beforeFirst() throws IOException
69 {
70 }
71
72
73 /**
74 * Tells if the cursor can return a next element
75 *
76 * @return true if there are some more elements
77 * @throws IOException
78 * @throws EndOfFileExceededException
79 */
80 public boolean hasNext() throws EndOfFileExceededException, IOException
81 {
82 return false;
83 }
84
85
86 /**
87 * Tells if the cursor can return a next key
88 *
89 * @return true if there are some more keys
90 * @throws IOException
91 * @throws EndOfFileExceededException
92 */
93 public boolean hasNextKey() throws EndOfFileExceededException, IOException
94 {
95 return false;
96 }
97
98
99 /**
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 }