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