com.unboundid.ldap.sdk.persist
Class PersistedObjects<T>

java.lang.Object
  extended by 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

@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 the search methods in the LDAPPersister class. However, it has a couple of notable differences from a standard Java Iterator object:

See Also:
Serialized Form

Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 the next() method returns null 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 interface java.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 a null return value from the next() 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).