org.apache.directory.ldap.client.api
Class EntryCursorImpl

java.lang.Object
  extended by org.apache.directory.api.ldap.model.cursor.AbstractCursor<Entry>
      extended by org.apache.directory.ldap.client.api.EntryCursorImpl
All Implemented Interfaces:
Iterable<Entry>, Cursor<Entry>, EntryCursor

public class EntryCursorImpl
extends AbstractCursor<Entry>
implements EntryCursor

An implementation of Cursor based on the underlying SearchFuture instance. Note: This is a forward only cursor hence the only valid operations are next(), get() and close()

Author:
Apache Directory Project

Constructor Summary
EntryCursorImpl(SearchCursor searchCursor)
          Instantiates a new search cursor, embedding a SearchCursor.
 
Method Summary
 void after(Entry element)
          This operation is not supported in SearchCursor.
 void afterLast()
          This operation is not supported in SearchCursor.
 boolean available()
          Determines whether or not a call to get() will succeed.
 void before(Entry element)
          This operation is not supported in SearchCursor.
 void beforeFirst()
          This operation is not supported in SearchCursor.
 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 first()
          This operation is not supported in SearchCursor.
 Entry get()
          Gets the object at the current position.
 int getMessageId()
          
 SearchResultDone getSearchResultDone()
          gives the SearchResultDone message received at the end of search results
 boolean last()
          This operation is not supported in SearchCursor.
 boolean next()
          Advances this Cursor to the next position.
 boolean previous()
          This operation is not supported in SearchCursor.
 
Methods inherited from class org.apache.directory.api.ldap.model.cursor.AbstractCursor
checkNotClosed, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, iterator, setClosureMonitor, toString
 
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
isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, setClosureMonitor, toString
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

EntryCursorImpl

public EntryCursorImpl(SearchCursor searchCursor)
Instantiates a new search cursor, embedding a SearchCursor.

Parameters:
searchCursor - the embedded SearchResponse cursor
Method Detail

next

public boolean next()
             throws LdapException,
                    CursorException,
                    IOException
Advances this Cursor to the next position. If called before explicitly positioning this Cursor, the position is presumed to be before the first element and this method moves the cursor forward to the first element.

Specified by:
next in interface Cursor<Entry>
Returns:
true if the advance succeeded, false otherwise
Throws:
LdapException - if we have get any LDAP exception while operating the cursor
CursorException - if there are problems advancing to this Cursor to the next position, or if this Cursor is closed
IOException - If we have had any IO Exception

get

public Entry get()
          throws CursorException,
                 IOException
Gets the object at the current position. Cursor implementations may choose to reuse element objects by re-populating them on advances instead of creating new objects on each advance.

Specified by:
get in interface Cursor<Entry>
Returns:
the object at the current position
Throws:
CursorException - if the object at this Cursor's current position cannot be retrieved, or if this Cursor is closed
IOException - If we have had any IO Exception

getSearchResultDone

public SearchResultDone getSearchResultDone()
gives the SearchResultDone message received at the end of search results

Specified by:
getSearchResultDone in interface EntryCursor
Returns:
the SearchResultDone message, null if the search operation fails for any reason

available

public boolean available()
Determines whether or not a call to get() will succeed.

Specified by:
available in interface Cursor<Entry>
Returns:
true if a call to the get() method will succeed, false otherwise

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<Entry>
Overrides:
close in class AbstractCursor<Entry>

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<Entry>
Overrides:
close in class AbstractCursor<Entry>
Parameters:
cause - exception thrown when this Cursor is accessed after close

after

public void after(Entry element)
           throws LdapException,
                  CursorException,
                  IOException
This operation is not supported in SearchCursor. Prepares this Cursor, so a subsequent call to Cursor#previous() with a true return value, will have positioned the Cursor on a dataSet element equal to or less than the element argument but not greater. A call to Cursor#next() with a true return value will position the Cursor on a dataSet element greater than the argument. If Cursor#next() returns false then the Cursor is past the last element and so all values in the dataSet are less than or equal to the argument. If Cursor#previous() returns false then the Cursor is positioned before the first element and all elements in the dataSet are greater than the argument.

Specified by:
after in interface Cursor<Entry>
Parameters:
element - the element to be positioned after
Throws:
LdapException
CursorException
IOException

afterLast

public void afterLast()
               throws LdapException,
                      CursorException,
                      IOException
This operation is not supported in SearchCursor. Positions this Cursor after the last element.

Specified by:
afterLast in interface Cursor<Entry>
Throws:
LdapException
CursorException
IOException

before

public void before(Entry element)
            throws LdapException,
                   CursorException,
                   IOException
This operation is not supported in SearchCursor. Prepares this Cursor, so a subsequent call to Cursor#next() with a true return value, will have positioned the Cursor on a dataSet element equal to or less than the element argument but not greater. A call to Cursor#previous() with a true return value will position the Cursor on a dataSet element less than the argument. If Cursor#next() returns false then the Cursor is past the last element and so all values in the dataSet are less than the argument. If Cursor#previous() returns false then the Cursor is positioned before the first element and all elements in the dataSet are greater than the argument.

Specified by:
before in interface Cursor<Entry>
Parameters:
element - the element to be positioned before
Throws:
LdapException
CursorException
IOException

beforeFirst

public void beforeFirst()
                 throws LdapException,
                        CursorException,
                        IOException
This operation is not supported in SearchCursor. Positions this Cursor before the first element.

Specified by:
beforeFirst in interface Cursor<Entry>
Throws:
LdapException
CursorException
IOException

first

public boolean first()
              throws LdapException,
                     CursorException,
                     IOException
This operation is not supported in SearchCursor. Positions this Cursor at the first element.

Specified by:
first in interface Cursor<Entry>
Returns:
true if the position has been successfully changed to the first element, false otherwise
Throws:
LdapException
CursorException
IOException

last

public boolean last()
             throws LdapException,
                    CursorException,
                    IOException
This operation is not supported in SearchCursor. Positions this Cursor at the last element.

Specified by:
last in interface Cursor<Entry>
Returns:
true if the position has been successfully changed to the last element, false otherwise
Throws:
LdapException
CursorException
IOException

previous

public boolean previous()
                 throws LdapException,
                        CursorException,
                        IOException
This operation is not supported in SearchCursor. Advances this Cursor to the previous position. If called before explicitly positioning this Cursor, the position is presumed to be after the last element and this method moves the cursor back to the last element.

Specified by:
previous in interface Cursor<Entry>
Returns:
true if the advance succeeded, false otherwise
Throws:
LdapException
CursorException
IOException

getMessageId

public int getMessageId()

Specified by:
getMessageId in interface EntryCursor
Returns:
the underlying message ID


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