org.apache.directory.shared.ldap.model.cursor
Class AbstractTupleCursor<K,V>

java.lang.Object
  extended by org.apache.directory.shared.ldap.model.cursor.AbstractTupleCursor<K,V>
Type Parameters:
K - The key type for the Tuple
V - The associated Value type
All Implemented Interfaces:
Iterable<Tuple<K,V>>, Cursor<Tuple<K,V>>, TupleCursor<K,V>

public abstract class AbstractTupleCursor<K,V>
extends Object
implements TupleCursor<K,V>

An abstract TupleCursor.

Author:
Apache Directory Project

Constructor Summary
AbstractTupleCursor()
           
 
Method Summary
protected  void checkNotClosed(String operation)
          Check if the cursor is closed for the given operation
 void close()
          Closes this Cursor and frees any resources it my have allocated.
 void close(Exception cause)
          Closes this Cursor and frees any resources it my have allocated.
 boolean isAfterLast()
          Is this Cursor positioned after the last element.
 boolean isBeforeFirst()
          Is this Cursor positioned before the first element.
 boolean isClosed()
          Checks if this Cursor is closed.
 boolean isFirst()
          Is this Cursor positioned at the first element.
 boolean isLast()
          Is this Cursor positioned at the last element.
 Iterator<Tuple<K,V>> iterator()
          
 void setClosureMonitor(ClosureMonitor monitor)
          Sets a non-null closure monitor to associate with this Cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.model.cursor.TupleCursor
afterKey, afterValue, beforeKey, beforeValue
 
Methods inherited from interface org.apache.directory.shared.ldap.model.cursor.Cursor
after, afterLast, available, before, beforeFirst, first, get, last, next, previous
 

Constructor Detail

AbstractTupleCursor

public AbstractTupleCursor()
Method Detail

setClosureMonitor

public final void setClosureMonitor(ClosureMonitor monitor)
Sets a non-null closure monitor to associate with this Cursor.

Specified by:
setClosureMonitor in interface Cursor<Tuple<K,V>>
Parameters:
monitor - the monitor to use for detecting Cursor close events

checkNotClosed

protected final void checkNotClosed(String operation)
                             throws Exception
Check if the cursor is closed for the given operation

Parameters:
operation - The operation that will be applied if the cursor is not closed
Throws:
Exception - If there is an issue

isClosed

public final boolean isClosed()
Checks if this Cursor is closed. Calls to this operation should not fail with exceptions if and only if the cursor is in the closed state.

Specified by:
isClosed in interface Cursor<Tuple<K,V>>
Returns:
true if this Cursor is closed, false otherwise

close

public void close()
           throws Exception
Closes this Cursor and frees any resources it my have allocated. Repeated calls to this method after this Cursor has already been called should not fail with exceptions.

Specified by:
close in interface Cursor<Tuple<K,V>>
Throws:
Exception - if for some reason this Cursor could not be closed

close

public void close(Exception cause)
           throws Exception
Closes this Cursor and frees any resources it my have allocated. Repeated calls to this method after this Cursor has already been called should not fail with exceptions. The reason argument is the Exception instance thrown instead of the standard CursorClosedException.

Specified by:
close in interface Cursor<Tuple<K,V>>
Parameters:
cause - exception thrown when this Cursor is accessed after close
Throws:
Exception - if for some reason this Cursor could not be closed

iterator

public Iterator<Tuple<K,V>> iterator()

Specified by:
iterator in interface Iterable<Tuple<K,V>>

isAfterLast

public boolean isAfterLast()
                    throws Exception
Is this Cursor positioned after the last element.

Specified by:
isAfterLast in interface Cursor<Tuple<K,V>>
Returns:
true if this cursor is positioned after the last element, false otherwise
Throws:
Exception - if there are problems querying the position of this Cursor or if this Cursor is closed

isBeforeFirst

public boolean isBeforeFirst()
                      throws Exception
Is this Cursor positioned before the first element.

Specified by:
isBeforeFirst in interface Cursor<Tuple<K,V>>
Returns:
true if this cursor is positioned before the first element, false otherwise
Throws:
Exception - if there are problems querying the position of this Cursor or if this Cursor is closed

isFirst

public boolean isFirst()
                throws Exception
Is this Cursor positioned at the first element.

Specified by:
isFirst in interface Cursor<Tuple<K,V>>
Returns:
true if this cursor is positioned at the first element, false otherwise
Throws:
Exception - if there are problems querying the position of this Cursor or if this Cursor is closed

isLast

public boolean isLast()
               throws Exception
Is this Cursor positioned at the last element.

Specified by:
isLast in interface Cursor<Tuple<K,V>>
Returns:
true if this cursor is positioned at the last element, false otherwise
Throws:
Exception - if there are problems querying the position of this Cursor or if this Cursor is closed


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.