org.apache.directory.shared.ldap.cursor
Class AbstractCursor<E>

java.lang.Object
  extended by org.apache.directory.shared.ldap.cursor.AbstractCursor<E>
All Implemented Interfaces:
java.lang.Iterable<E>, Cursor<E>
Direct Known Subclasses:
EmptyCursor, ListCursor, SingletonCursor

public abstract class AbstractCursor<E>
extends java.lang.Object
implements Cursor<E>

Simple class that contains often used Cursor code.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Constructor Summary
AbstractCursor()
           
 
Method Summary
protected  void checkNotClosed(java.lang.String operation)
          Check that the cursor is not closed.
 void close()
          Closes this Cursor and frees any resources it my have allocated.
 void close(java.lang.Exception cause)
          Closes this Cursor and frees any resources it my have allocated.
 boolean isClosed()
          Checks if this Cursor is closed.
 java.util.Iterator<E> 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.cursor.Cursor
after, afterLast, available, before, beforeFirst, first, get, isElementReused, last, next, previous
 

Constructor Detail

AbstractCursor

public AbstractCursor()
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<E>
Parameters:
monitor - the monitor to use for detecting Cursor close events

checkNotClosed

protected final void checkNotClosed(java.lang.String operation)
                             throws java.lang.Exception
Check that the cursor is not closed.

Parameters:
operation -
Throws:
java.lang.Exception

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<E>
Returns:
true if this Cursor is closed, false otherwise

close

public void close(java.lang.Exception cause)
           throws java.lang.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<E>
Parameters:
cause - exception thrown when this Cursor is accessed after close
Throws:
java.lang.Exception - if for some reason this Cursor could not be closed

close

public void close()
           throws java.lang.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<E>
Throws:
java.lang.Exception - if for some reason this Cursor could not be closed

iterator

public java.util.Iterator<E> iterator()

Specified by:
iterator in interface java.lang.Iterable<E>


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.