Package com.unboundid.ldap.sdk.persist
Class PersistedObjects<T>
java.lang.Object
com.unboundid.ldap.sdk.persist.PersistedObjects<T>
- Type Parameters:
T- The type of object handled by this class.
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable
@ThreadSafety(level=NOT_THREADSAFE)
public final class PersistedObjects<T>
extends Object
implements Serializable, Closeable
This class provides a mechanism for iterating through the objects returned
by a search operation performed using one of the
search methods in
the LDAPPersister class. However, it has a couple of notable
differences from a standard Java Iterator object:
- It does not have a
hasNextmethod. Instead, thenext()method will returnnullwhen there are no more objects in the set of results. - The
next()method may throw an exception if a problem occurs while trying to read an entry or decode it as an object of the appropriate type. This does not necessarily mean that the search is complete, and thenext()method should be called again to see if there are any more objects to retrieve. - If you wish to stop iterating through the results before all of them
have been retrieved, then you must call the
close()method
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Indicates that you wish to stop iterating through search results and will not be retrieving any additional objects.Retrieves the search result for the search operation, if available.next()Retrieves the next object returned from the search request.
-
Method Details
-
next
Retrieves the next object returned from the search request. This method may block until the necessary information has been received from the server.- Returns:
- The next object returned from the search request, or
nullif all objects have been read. - Throws:
LDAPPersistException- If a problem occurs while reading the next entry from the server, or when trying to decode that entry as an object.
-
close
Indicates that you wish to stop iterating through search results and will not be retrieving any additional objects. This method MUST be called to avoid leaking resources if you stop iterating through results before thenext()method returnsnullto indicate that there are no more objects to retrieve. This method MAY be called after the search has completed (including being called multiple times) with no adverse effects.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getSearchResult
Retrieves the search result for the search operation, if available. It will not be available until the search has completed (as indicated by anullreturn value from thenext()method), and for some use cases it may never be available.- Returns:
- The search result for the search operation, or
nullif it is not available (e.g., because the search has not yet completed).
-