org.apache.directory.api.ldap.model.cursor
Class AbstractCursor<E>

java.lang.Object
  extended by org.apache.directory.api.ldap.model.cursor.AbstractCursor<E>
Type Parameters:
E - The type of element on which this cursor will iterate
All Implemented Interfaces:
Iterable<E>, Cursor<E>
Direct Known Subclasses:
EmptyCursor, ListCursor, SetCursor, SingletonCursor

public abstract class AbstractCursor<E>
extends Object
implements Cursor<E>

Simple class that contains often used Cursor code.

Author:
Apache Directory Project

Constructor Summary
AbstractCursor()
           
 
Method Summary
 void checkNotClosed(String operation)
          Check that the cursor is not closed before executing an 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<E> iterator()
          
 void setClosureMonitor(ClosureMonitor monitor)
          Sets a non-null closure monitor to associate with this Cursor.
 String toString(String tabs)
          Pretty-print a cursor and its wrapped 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.api.ldap.model.cursor.Cursor
after, afterLast, available, before, beforeFirst, first, get, last, next, previous
 

Constructor Detail

AbstractCursor

public AbstractCursor()
Method Detail

setClosureMonitor

public 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

public final void checkNotClosed(String operation)
                          throws CursorClosedException
Check that the cursor is not closed before executing an operation.

Parameters:
operation - The operation we try to execute
Throws:
CursorClosedException - If there is a problem during the check

isClosed

public 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(Exception cause)
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

close

public void close()
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>

iterator

public Iterator<E> iterator()

Specified by:
iterator in interface Iterable<E>

isAfterLast

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

Specified by:
isAfterLast in interface Cursor<E>
Returns:
true if this cursor is positioned after the last element, false otherwise

isBeforeFirst

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

Specified by:
isBeforeFirst in interface Cursor<E>
Returns:
true if this cursor is positioned before the first element, false otherwise

isFirst

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

Specified by:
isFirst in interface Cursor<E>
Returns:
true if this cursor is positioned at the first element, false otherwise

isLast

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

Specified by:
isLast in interface Cursor<E>
Returns:
true if this cursor is positioned at the last element, false otherwise

toString

public String toString(String tabs)
Pretty-print a cursor and its wrapped cursor.

Specified by:
toString in interface Cursor<E>
Parameters:
tabs - The spaces to add at each level
Returns:
The cursor and all it's wrapped elements, recursively printed


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