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 */ 020package org.apache.directory.server.xdbm; 021 022 023import org.apache.directory.api.ldap.model.cursor.AbstractCursor; 024import org.apache.directory.api.ldap.model.cursor.CursorException; 025import org.apache.directory.api.ldap.model.exception.LdapException; 026import org.apache.directory.server.core.api.partition.PartitionTxn; 027 028 029/** 030 * An abstract Cursor used by the index cursors. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public abstract class AbstractIndexCursor<V> extends AbstractCursor<IndexEntry<V, String>> 035{ 036 /** Tells if there are some element available in the cursor */ 037 private boolean available = false; 038 039 /** A transaction associated with this cursor */ 040 protected PartitionTxn partitionTxn; 041 042 /** The message used for unsupported operations */ 043 protected static final String UNSUPPORTED_MSG = "Unsupported operation"; 044 045 046 /** 047 * {@inheritDoc} 048 */ 049 public boolean available() 050 { 051 return available; 052 } 053 054 055 /** 056 * Gets the message to return for operations that are not supported 057 * 058 * @return The Unsupported message 059 */ 060 protected abstract String getUnsupportedMessage(); 061 062 063 /** 064 * {@inheritDoc} 065 */ 066 public void after( IndexEntry<V, String> element ) throws LdapException, CursorException 067 { 068 throw new UnsupportedOperationException( getUnsupportedMessage() ); 069 } 070 071 072 /** 073 * {@inheritDoc} 074 */ 075 public void before( IndexEntry<V, String> element ) throws LdapException, CursorException 076 { 077 throw new UnsupportedOperationException( getUnsupportedMessage() ); 078 } 079 080 081 /** 082 * {@inheritDoc} 083 */ 084 protected boolean setAvailable( boolean available ) 085 { 086 this.available = available; 087 return available; 088 } 089 090 091 092 @Override 093 public boolean previous() throws LdapException, CursorException 094 { 095 return false; 096 } 097 098 099 @Override 100 public boolean next() throws LdapException, CursorException 101 { 102 return false; 103 } 104}