com.unboundid.ldap.sdk
Class SearchResult

java.lang.Object
  extended by com.unboundid.ldap.sdk.LDAPResult
      extended by 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 the LDAPResult object, but also contains additional information specific to the search operation. This includes:

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.unboundid.ldap.protocol.LDAPResponse
NO_CONTROLS
 
Constructor Summary
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.
 
Method Summary
 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, getReferralURLs, getResponseControl, getResponseControls, getResultCode, hasResponseControl, hasResponseControl, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchResult

public 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. This version of the constructor should be used if the search result entries and references were returned to the client via the SearchResultListener 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,
                    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. 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 the SearchResultListener 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 be null if the search result entries were returned through the SearchResultListener interface.
searchReferences - A list containing the set of search result references returned by the server. It may only be null if the search result entries were returned through the SearchResultListener 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.
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

public java.util.List<SearchResultEntry> getSearchEntries()
Retrieves a list containing the matching entries returned from the search operation. This will only be available if a SearchResultListener was not used during the search.

Returns:
A list containing the matching entries returned from the search operation, or null if a SearchResultListener was used during the search.

getSearchEntry

public SearchResultEntry getSearchEntry(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 a SearchResultListener was not used during the search.

Parameters:
dn - The DN of the search result entry to retrieve. It must not be null.
Returns:
The search result entry with the provided DN, or null if the specified entry was not returned, or if a SearchResultListener 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

public java.util.List<SearchResultReference> getSearchReferences()
Retrieves a list containing the search references returned from the search operation. This will only be available if a SearchResultListener 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 a SearchResultListener was used during the search.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP result to the provided buffer.

Specified by:
toString in interface LDAPResponse
Overrides:
toString in class LDAPResult
Parameters:
buffer - The buffer to which to append a string representation of this LDAP result.