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:
java.io.Closeable
,java.io.Serializable
,java.lang.AutoCloseable
@ThreadSafety(level=NOT_THREADSAFE) public final class PersistedObjects<T> extends java.lang.Object implements java.io.Serializable, java.io.Closeable
This class provides a mechanism for iterating through the objects returned by a search operation performed using one of thesearch
methods in theLDAPPersister
class. However, it has a couple of notable differences from a standard JavaIterator
object:- It does not have a
hasNext
method. Instead, thenext()
method will returnnull
when 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:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Indicates that you wish to stop iterating through search results and will not be retrieving any additional objects.SearchResult
getSearchResult()
Retrieves the search result for the search operation, if available.T
next()
Retrieves the next object returned from the search request.
-
-
-
Method Detail
-
next
public T next() throws LDAPPersistException
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
null
if 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
public void 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 returnsnull
to 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
getSearchResult
public SearchResult getSearchResult()
Retrieves the search result for the search operation, if available. It will not be available until the search has completed (as indicated by anull
return value from thenext()
method), and for some use cases it may never be available.- Returns:
- The search result for the search operation, or
null
if it is not available (e.g., because the search has not yet completed).
-
-