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.shared.ldap.cursor; 020 021 import org.apache.directory.shared.i18n.I18n; 022 023 024 /** 025 * An empty Cursor implementation. 026 * 027 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 028 * @version $Rev$, $Date$ 029 */ 030 public class EmptyCursor<E> extends AbstractCursor<E> 031 { 032 /** 033 * {@inheritDoc} 034 */ 035 public boolean available() 036 { 037 return false; 038 } 039 040 /** 041 * {@inheritDoc} 042 */ 043 public void before( E element ) throws Exception 044 { 045 checkNotClosed( "before()" ); 046 } 047 048 049 /** 050 * {@inheritDoc} 051 */ 052 public void after( E element ) throws Exception 053 { 054 checkNotClosed( "after()" ); 055 } 056 057 058 /** 059 * {@inheritDoc} 060 */ 061 public void beforeFirst() throws Exception 062 { 063 checkNotClosed( "beforeFirst()" ); 064 } 065 066 067 /** 068 * {@inheritDoc} 069 */ 070 public void afterLast() throws Exception 071 { 072 checkNotClosed( "afterLast()" ); 073 } 074 075 076 /** 077 * {@inheritDoc} 078 */ 079 public boolean first() throws Exception 080 { 081 checkNotClosed( "first()" ); 082 return false; 083 } 084 085 086 /** 087 * {@inheritDoc} 088 */ 089 public boolean last() throws Exception 090 { 091 checkNotClosed( "last()" ); 092 return false; 093 } 094 095 096 /** 097 * {@inheritDoc} 098 */ 099 public boolean previous() throws Exception 100 { 101 checkNotClosed( "previous()" ); 102 return false; 103 } 104 105 106 /** 107 * {@inheritDoc} 108 */ 109 public boolean next() throws Exception 110 { 111 checkNotClosed( "next()" ); 112 return false; 113 } 114 115 116 /** 117 * {@inheritDoc} 118 */ 119 public E get() throws Exception 120 { 121 checkNotClosed( "get()" ); 122 throw new InvalidCursorPositionException( I18n.err( I18n.ERR_02004 ) ); 123 } 124 125 126 /** 127 * {@inheritDoc} 128 */ 129 public boolean isElementReused() 130 { 131 return false; 132 } 133 }