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    package org.apache.directory.server.xdbm;
020    
021    import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
022    
023    
024    
025    /**
026     * An empty Cursor implementation.
027     *
028     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
029     * @version $Rev$, $Date$
030     */
031    public class EmptyIndexCursor<K,E> extends AbstractIndexCursor<K,E>
032    {
033        public boolean available()
034        {
035            return false;
036        }
037    
038        public void before( IndexEntry<K,E> element ) throws Exception
039        {
040            checkNotClosed( "before()" );
041        }
042    
043    
044        public void after( IndexEntry<K,E> element ) throws Exception
045        {
046            checkNotClosed( "after()" );
047        }
048    
049    
050        public void beforeFirst() throws Exception
051        {
052            checkNotClosed( "beforeFirst()" );
053        }
054    
055    
056        public void afterLast() throws Exception
057        {
058            checkNotClosed( "afterLast()" );
059        }
060    
061    
062        public boolean first() throws Exception
063        {
064            checkNotClosed( "first()" );
065            return false;
066        }
067    
068    
069        public boolean last() throws Exception
070        {
071            checkNotClosed( "last()" );
072            return false;
073        }
074    
075    
076        public boolean previous() throws Exception
077        {
078            checkNotClosed( "previous()" );
079            return false;
080        }
081    
082    
083        public boolean next() throws Exception
084        {
085            checkNotClosed( "next()" );
086            return false;
087        }
088    
089    
090        public IndexEntry<K,E> get() throws Exception
091        {
092            checkNotClosed( "get()" );
093            throw new InvalidCursorPositionException( "This cursor is empty and cannot return elements!" );
094        }
095    
096    
097        public boolean isElementReused()
098        {
099            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    }