Package org.ldaptive
Class SearchResponse
- java.lang.Object
-
- org.ldaptive.AbstractMessage
-
- org.ldaptive.AbstractResult
-
- org.ldaptive.SearchResponse
-
public class SearchResponse extends AbstractResult
Response that encapsulates the result elements of a search request. This class formally decodes the SearchResultDone LDAP message defined as:SearchResultDone ::= [APPLICATION 5] LDAPResult
- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SearchResponse.Builder
-
Nested classes/interfaces inherited from class org.ldaptive.AbstractResult
AbstractResult.AbstractBuilder<B,T extends AbstractResult>, AbstractResult.DiagnosticMessageHandler, AbstractResult.MatchedDNHandler, AbstractResult.ReferralHandler, AbstractResult.ResultCodeHandler
-
Nested classes/interfaces inherited from class org.ldaptive.AbstractMessage
AbstractMessage.ControlParser, AbstractMessage.ControlsHandler, AbstractMessage.MessageIDHandler
-
-
Field Summary
Fields Modifier and Type Field Description static int
PROTOCOL_OP
BER protocol number.-
Fields inherited from interface org.ldaptive.Result
ENCODE_CNTRL_CHARS
-
-
Constructor Summary
Constructors Constructor Description SearchResponse()
Default constructor.SearchResponse(DERBuffer buffer)
Creates a new search result done.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntries(java.util.Collection<LdapEntry> entries)
Adds entry(s) to this search result.void
addEntries(LdapEntry... entry)
Adds an entry to this search result.void
addReferences(java.util.Collection<SearchResultReference> references)
Adds references(s) to this search result.void
addReferences(SearchResultReference... reference)
Adds a reference to this search result.static SearchResponse.Builder
builder()
Creates a builder for this class.int
entrySize()
Returns the number of entries in this search result.boolean
equals(java.lang.Object o)
java.util.Collection<LdapEntry>
getEntries()
Returns a collection of ldap entry.LdapEntry
getEntry()
Returns a single entry of this result.LdapEntry
getEntry(java.lang.String dn)
Returns the ldap in this result with the supplied DN.java.util.Set<java.lang.String>
getEntryDns()
Returns the entry DNs in this result.SearchResultReference
getReference()
Returns a single search reference of this result.java.util.Collection<SearchResultReference>
getReferences()
Returns a collection of ldap entry.int
hashCode()
Returns the hash code for this object.void
initialize(SearchResponse result)
Copies the values of the supplied search result done to this synthetic result.static SearchResponse
merge(SearchResponse result)
Merges the entries in the supplied result into a single entry.int
referenceSize()
Returns the number of references in this search result.static SearchResponse
sort(SearchResponse sr)
Returns a new response whose entries are sorted naturally by DN.SearchResponse
subResult(int fromIndex, int toIndex)
Returns a portion of this result between the specified fromIndex, inclusive, and toIndex, exclusive.java.lang.String
toString()
-
Methods inherited from class org.ldaptive.AbstractResult
addReferralURLs, copyValues, getDiagnosticMessage, getMatchedDN, getReferralURLs, getResultCode, setDiagnosticMessage, setMatchedDN, setResultCode
-
Methods inherited from class org.ldaptive.AbstractMessage
addControls, copyValues, getControls, getMessageID, setMessageID
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ldaptive.Message
getControl, getControls, getMessageID
-
Methods inherited from interface org.ldaptive.Result
getEncodedDiagnosticMessage, isSuccess
-
-
-
-
Field Detail
-
PROTOCOL_OP
public static final int PROTOCOL_OP
BER protocol number.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SearchResponse
public SearchResponse()
Default constructor.
-
SearchResponse
public SearchResponse(DERBuffer buffer)
Creates a new search result done.- Parameters:
buffer
- to decode
-
-
Method Detail
-
initialize
public void initialize(SearchResponse result)
Copies the values of the supplied search result done to this synthetic result.- Parameters:
result
- of values to copy
-
getEntries
public java.util.Collection<LdapEntry> getEntries()
Returns a collection of ldap entry.- Returns:
- collection of ldap entry
-
getEntry
public LdapEntry getEntry()
Returns a single entry of this result. If multiple entries exist the first entry returned by the underlying iterator is used. If no entries exist null is returned.- Returns:
- search result entry
-
getEntry
public LdapEntry getEntry(java.lang.String dn)
Returns the ldap in this result with the supplied DN.- Parameters:
dn
- of the entry to return- Returns:
- search result entry
-
getEntryDns
public java.util.Set<java.lang.String> getEntryDns()
Returns the entry DNs in this result.- Returns:
- string array of entry DNs
-
addEntries
public void addEntries(LdapEntry... entry)
Adds an entry to this search result.- Parameters:
entry
- entry to add
-
addEntries
public void addEntries(java.util.Collection<LdapEntry> entries)
Adds entry(s) to this search result.- Parameters:
entries
- collection of entries to add
-
entrySize
public int entrySize()
Returns the number of entries in this search result.- Returns:
- number of entries in this search result
-
getReferences
public java.util.Collection<SearchResultReference> getReferences()
Returns a collection of ldap entry.- Returns:
- collection of ldap entry
-
getReference
public SearchResultReference getReference()
Returns a single search reference of this result. If multiple references exist the first references returned by the underlying iterator is used. If no references exist null is returned.- Returns:
- search result references
-
addReferences
public void addReferences(SearchResultReference... reference)
Adds a reference to this search result.- Parameters:
reference
- reference to add
-
addReferences
public void addReferences(java.util.Collection<SearchResultReference> references)
Adds references(s) to this search result.- Parameters:
references
- collection of references to add
-
referenceSize
public int referenceSize()
Returns the number of references in this search result.- Returns:
- number of references in this search result
-
subResult
public SearchResponse subResult(int fromIndex, int toIndex)
Returns a portion of this result between the specified fromIndex, inclusive, and toIndex, exclusive. If fromIndex and toIndex are equal, the return result is empty. The result of this method is undefined for unordered results.- Parameters:
fromIndex
- low endpoint of the search result (inclusive)toIndex
- high endpoint of the search result (exclusive)- Returns:
- portion of this search result
- Throws:
java.lang.IndexOutOfBoundsException
- for illegal index values
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classAbstractResult
-
hashCode
public int hashCode()
Description copied from class:AbstractMessage
Returns the hash code for this object.- Specified by:
hashCode
in classAbstractMessage
- Returns:
- hash code
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractResult
-
sort
public static SearchResponse sort(SearchResponse sr)
Returns a new response whose entries are sorted naturally by DN. Each attribute and each attribute value are also sorted. SeeLdapEntry.sort(LdapEntry)
andLdapAttribute.sort(LdapAttribute)
.- Parameters:
sr
- response to sort- Returns:
- sorted response
-
merge
public static SearchResponse merge(SearchResponse result)
Merges the entries in the supplied result into a single entry. This method always returns a search result of size zero or one.- Parameters:
result
- search result containing entries to merge- Returns:
- search result containing a single merged entry
-
builder
public static SearchResponse.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-