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

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 hasNext method. Instead, the next() method will return null 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 the next() 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 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 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 AutoCloseable
      Specified by:
      close in interface Closeable
    • 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).