Class SearchCursorImpl
- java.lang.Object
-
- org.apache.directory.api.ldap.model.cursor.AbstractCursor<Response>
-
- org.apache.directory.ldap.client.api.SearchCursorImpl
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Response>,Cursor<Response>,SearchCursor
public class SearchCursorImpl extends AbstractCursor<Response> implements SearchCursor
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
Constructors Constructor Description SearchCursorImpl(SearchFuture future, long timeout, TimeUnit timeUnit)Instantiates a new search cursor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafter(Response element)This operation is not supported in SearchCursor.voidafterLast()This operation is not supported in SearchCursor.booleanavailable()Determines whether or not a call to get() will succeed.voidbefore(Response element)This operation is not supported in SearchCursor.voidbeforeFirst()This operation is not supported in SearchCursor.voidclose()voidclose(Exception cause)Closes this Cursor and frees any resources it my have allocated.booleanfirst()This operation is not supported in SearchCursor.Responseget()Gets the object at the current position.EntrygetEntry()IntermediateResponsegetIntermediate()ReferralgetReferral()SearchResultDonegetSearchResultDone()gives the SearchResultDone message received at the end of search resultsbooleanisDone()booleanisEntry()booleanisIntermediate()booleanisReferral()booleanlast()This operation is not supported in SearchCursor.booleannext()Advances this Cursor to the next position.booleanprevious()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
forEach, iterator, spliterator
-
-
-
-
Constructor Detail
-
SearchCursorImpl
public SearchCursorImpl(SearchFuture future, long timeout, TimeUnit timeUnit)
Instantiates a new search cursor.- Parameters:
future- the futuretimeout- the timeouttimeUnit- the time unit
-
-
Method Detail
-
next
public boolean next() throws LdapException, CursorExceptionAdvances 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:
nextin interfaceCursor<Response>- Returns:
- true if the advance succeeded, false otherwise
- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor to the next position, or if this Cursor is closed
-
get
public Response get() throws InvalidCursorPositionException
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:
getin interfaceCursor<Response>- Returns:
- the object at the current position
- Throws:
InvalidCursorPositionException
-
getSearchResultDone
public SearchResultDone getSearchResultDone()
gives the SearchResultDone message received at the end of search results- Specified by:
getSearchResultDonein interfaceSearchCursor- 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.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractCursor<Response>- Throws:
IOException
-
close
public void close(Exception cause) throws IOException
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:
closein interfaceCursor<Response>- Overrides:
closein classAbstractCursor<Response>- Parameters:
cause- exception thrown when this Cursor is accessed after close- Throws:
IOException- If we can't close the Cursor
-
after
public void after(Response element) throws LdapException, CursorException
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:
afterin interfaceCursor<Response>- Parameters:
element- the element to be positioned after- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor after the given element, or if this Cursor is closed
-
afterLast
public void afterLast() throws LdapException, CursorExceptionThis operation is not supported in SearchCursor. Positions this Cursor after the last element.- Specified by:
afterLastin interfaceCursor<Response>- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor after the last position, or if this Cursor is closed
-
before
public void before(Response element) throws LdapException, CursorException
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:
beforein interfaceCursor<Response>- Parameters:
element- the element to be positioned before- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor before the given element, or if this Cursor is closed
-
beforeFirst
public void beforeFirst() throws LdapException, CursorExceptionThis operation is not supported in SearchCursor. Positions this Cursor before the first element.- Specified by:
beforeFirstin interfaceCursor<Response>- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor before the first position, or if this Cursor is closed
-
first
public boolean first() throws LdapException, CursorExceptionThis operation is not supported in SearchCursor. Positions this Cursor at the first element.- Specified by:
firstin interfaceCursor<Response>- Returns:
- true if the position has been successfully changed to the first element, false otherwise
- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor to the first position, or if this Cursor is closed
-
last
public boolean last() throws LdapException, CursorExceptionThis operation is not supported in SearchCursor. Positions this Cursor at the last element.- Specified by:
lastin interfaceCursor<Response>- Returns:
- true if the position has been successfully changed to the last element, false otherwise
- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor to the last position, or if this Cursor is closed
-
previous
public boolean previous() throws LdapException, CursorExceptionThis 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:
previousin interfaceCursor<Response>- Returns:
- true if the advance succeeded, false otherwise
- Throws:
LdapException- if we have get any LDAP exception while operating the cursorCursorException- if there are problems advancing to this Cursor to the previous position, or if this Cursor is closed
-
isDone
public boolean isDone()
- Specified by:
isDonein interfaceSearchCursor- Returns:
- true if the cursor has processed all the elements we were searching
-
isReferral
public boolean isReferral()
- Specified by:
isReferralin interfaceSearchCursor- Returns:
- true if the next element in the cursor is a referral
-
getReferral
public Referral getReferral() throws LdapException
- Specified by:
getReferralin interfaceSearchCursor- Returns:
- The next referral element, if it's a referral
- Throws:
LdapException- If the
-
isEntry
public boolean isEntry()
- Specified by:
isEntryin interfaceSearchCursor- Returns:
- true if the next element in the cursor is an entry
-
getEntry
public Entry getEntry() throws LdapException
- Specified by:
getEntryin interfaceSearchCursor- Returns:
- The next entry element, if it's an entry
- Throws:
LdapException- If the
-
isIntermediate
public boolean isIntermediate()
- Specified by:
isIntermediatein interfaceSearchCursor- Returns:
- true if the next element in the cursor is an intermediate response
-
getIntermediate
public IntermediateResponse getIntermediate() throws LdapException
- Specified by:
getIntermediatein interfaceSearchCursor- Returns:
- The next intermediate response element, if it's an intermediate response
- Throws:
LdapException- If the
-
-