Package com.unboundid.ldap.sdk
Class SearchResult
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPResult
-
- com.unboundid.ldap.sdk.SearchResult
-
- All Implemented Interfaces:
LDAPResponse
,java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class SearchResult extends LDAPResult
This class provides a data structure for holding information about the result of processing a search request. This includes the elements of theLDAPResult
object, but also contains additional information specific to the search operation. This includes:- The number of
SearchResultEntry
objects returned from the server. This will be available regardless of whether the entries are included in this search result object or were returned through aSearchResultListener
. - The number of
SearchResultReference
objects returned from the server. This will be available regardless of whether the entries are included in this search result object or were returned through aSearchResultListener
. - A list of the
SearchResultEntry
objects returned from the server. This will benull
if aSearchResultListener
was used to return the entries. - A list of the
SearchResultReference
objects returned from the server. This will benull
if aSearchResultListener
was used to return the entries.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface com.unboundid.ldap.protocol.LDAPResponse
NO_CONTROLS
-
-
Constructor Summary
Constructors Constructor Description SearchResult(int messageID, ResultCode resultCode, java.lang.String diagnosticMessage, java.lang.String matchedDN, java.lang.String[] referralURLs, int numEntries, int numReferences, Control[] responseControls)
Creates a new search result object with the provided information.SearchResult(int messageID, ResultCode resultCode, java.lang.String diagnosticMessage, java.lang.String matchedDN, java.lang.String[] referralURLs, java.util.List<SearchResultEntry> searchEntries, java.util.List<SearchResultReference> searchReferences, int numEntries, int numReferences, Control[] responseControls)
Creates a new search result object with the provided information.SearchResult(LDAPException ldapException)
Creates a new search result object with the information from the provided LDAP exception.SearchResult(LDAPResult ldapResult)
Creates a new search result object with the information from the provided LDAP result.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getEntryCount()
Retrieves the number of matching entries returned for the search operation.int
getReferenceCount()
Retrieves the number of search references returned for the search operation.java.util.List<SearchResultEntry>
getSearchEntries()
Retrieves a list containing the matching entries returned from the search operation.SearchResultEntry
getSearchEntry(java.lang.String dn)
Retrieves the search result entry with the specified DN from the set of entries returned.java.util.List<SearchResultReference>
getSearchReferences()
Retrieves a list containing the search references returned from the search operation.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP result to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.LDAPResult
getDiagnosticMessage, getMatchedDN, getMessageID, getOperationType, getReferralURLs, getResponseControl, getResponseControls, getResultCode, getResultString, hasResponseControl, hasResponseControl, toString
-
-
-
-
Constructor Detail
-
SearchResult
public SearchResult(int messageID, @NotNull ResultCode resultCode, @Nullable java.lang.String diagnosticMessage, @Nullable java.lang.String matchedDN, @Nullable java.lang.String[] referralURLs, int numEntries, int numReferences, @Nullable Control[] responseControls)
Creates a new search result object with the provided information. This version of the constructor should be used if the search result entries and references were returned to the client via theSearchResultListener
interface.- Parameters:
messageID
- The message ID for the LDAP message that is associated with this LDAP result.resultCode
- The result code from the search result done response.diagnosticMessage
- The diagnostic message from the search result done response, if available.matchedDN
- The matched DN from the search result done response, if available.referralURLs
- The set of referral URLs from the search result done response, if available.numEntries
- The number of search result entries returned for this search.numReferences
- The number of search result references returned for this search.responseControls
- The set of controls from the search result done response, if available.
-
SearchResult
public SearchResult(int messageID, @NotNull ResultCode resultCode, @Nullable java.lang.String diagnosticMessage, @Nullable java.lang.String matchedDN, @Nullable java.lang.String[] referralURLs, @Nullable java.util.List<SearchResultEntry> searchEntries, @Nullable java.util.List<SearchResultReference> searchReferences, int numEntries, int numReferences, @Nullable Control[] responseControls)
Creates a new search result object with the provided information. This version of the constructor should be used if the search result entries and references were collected in lists rather than returned to the requester through theSearchResultListener
interface.- Parameters:
messageID
- The message ID for the LDAP message that is associated with this LDAP result.resultCode
- The result code from the search result done response.diagnosticMessage
- The diagnostic message from the search result done response, if available.matchedDN
- The matched DN from the search result done response, if available.referralURLs
- The set of referral URLs from the search result done response, if available.searchEntries
- A list containing the set of search result entries returned by the server. It may only benull
if the search result entries were returned through theSearchResultListener
interface.searchReferences
- A list containing the set of search result references returned by the server. It may only benull
if the search result entries were returned through theSearchResultListener
interface.numEntries
- The number of search result entries returned for this search.numReferences
- The number of search result references returned for this search.responseControls
- The set of controls from the search result done response, if available.
-
SearchResult
public SearchResult(@NotNull LDAPResult ldapResult)
Creates a new search result object with the information from the provided LDAP result.- Parameters:
ldapResult
- The LDAP result to use to create the contents of this search result.
-
SearchResult
public SearchResult(@NotNull LDAPException ldapException)
Creates a new search result object with the information from the provided LDAP exception.- Parameters:
ldapException
- The LDAP exception to use to create the contents of this search result.
-
-
Method Detail
-
getEntryCount
public int getEntryCount()
Retrieves the number of matching entries returned for the search operation.- Returns:
- The number of matching entries returned for the search operation.
-
getReferenceCount
public int getReferenceCount()
Retrieves the number of search references returned for the search operation. This may be zero even if search references were received if the connection used when processing the search was configured to automatically follow referrals.- Returns:
- The number of search references returned for the search operation.
-
getSearchEntries
@Nullable public java.util.List<SearchResultEntry> getSearchEntries()
Retrieves a list containing the matching entries returned from the search operation. This will only be available if aSearchResultListener
was not used during the search.- Returns:
- A list containing the matching entries returned from the search
operation, or
null
if aSearchResultListener
was used during the search.
-
getSearchEntry
@Nullable public SearchResultEntry getSearchEntry(@NotNull java.lang.String dn) throws LDAPException
Retrieves the search result entry with the specified DN from the set of entries returned. This will only be available if aSearchResultListener
was not used during the search.- Parameters:
dn
- The DN of the search result entry to retrieve. It must not benull
.- Returns:
- The search result entry with the provided DN, or
null
if the specified entry was not returned, or if aSearchResultListener
was used for the search. - Throws:
LDAPException
- If a problem is encountered while attempting to parse the provided DN or a search entry DN.
-
getSearchReferences
@Nullable public java.util.List<SearchResultReference> getSearchReferences()
Retrieves a list containing the search references returned from the search operation. This will only be available if aSearchResultListener
was not used during the search, and may be empty even if search references were received if the connection used when processing the search was configured to automatically follow referrals.- Returns:
- A list containing the search references returned from the search
operation, or
null
if aSearchResultListener
was used during the search.
-
toString
public void toString(@NotNull java.lang.StringBuilder buffer)
Appends a string representation of this LDAP result to the provided buffer.- Specified by:
toString
in interfaceLDAPResponse
- Overrides:
toString
in classLDAPResult
- Parameters:
buffer
- The buffer to which to append a string representation of this LDAP result.
-
-