View Javadoc

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  package org.apache.directory.server.xdbm;
20  
21  
22  import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
23  
24  
25  /**
26   * An empty Cursor implementation.
27   *
28   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
29   * @version $Rev$, $Date$
30   */
31  public class EmptyIndexCursor<K,E> extends AbstractIndexCursor<K,E>
32  {
33      public boolean available()
34      {
35          return false;
36      }
37  
38      public void before( IndexEntry<K,E> element ) throws Exception
39      {
40          checkNotClosed( "before()" );
41      }
42  
43  
44      public void after( IndexEntry<K,E> element ) throws Exception
45      {
46          checkNotClosed( "after()" );
47      }
48  
49  
50      public void beforeFirst() throws Exception
51      {
52          checkNotClosed( "beforeFirst()" );
53      }
54  
55  
56      public void afterLast() throws Exception
57      {
58          checkNotClosed( "afterLast()" );
59      }
60  
61  
62      public boolean first() throws Exception
63      {
64          checkNotClosed( "first()" );
65          return false;
66      }
67  
68  
69      public boolean last() throws Exception
70      {
71          checkNotClosed( "last()" );
72          return false;
73      }
74  
75  
76      public boolean previous() throws Exception
77      {
78          checkNotClosed( "previous()" );
79          return false;
80      }
81  
82  
83      public boolean next() throws Exception
84      {
85          checkNotClosed( "next()" );
86          return false;
87      }
88  
89  
90      public IndexEntry<K,E> get() throws Exception
91      {
92          checkNotClosed( "get()" );
93          throw new InvalidCursorPositionException( "This cursor is empty and cannot return elements!" );
94      }
95  
96  
97      public boolean isElementReused()
98      {
99          return false;
100     }
101 
102     public void afterValue( Long id, K indexValue ) throws Exception
103     {
104         checkNotClosed( "after()" );
105     }
106 
107     public void beforeValue( Long id, K indexValue ) throws Exception
108     {
109         checkNotClosed( "after()" );
110     }
111 }