org.ldaptive
Class SearchResult

java.lang.Object
  extended by org.ldaptive.AbstractLdapBean
      extended by org.ldaptive.SearchResult
All Implemented Interfaces:
Serializable

public class SearchResult
extends AbstractLdapBean

Simple bean representing an ldap search result. Contains a map of entry DN to ldap entry.

Version:
$Revision: 3006 $ $Date: 2014-07-02 10:22:50 -0400 (Wed, 02 Jul 2014) $
Author:
Middleware Services
See Also:
Serialized Form

Constructor Summary
SearchResult()
          Default constructor.
SearchResult(Collection<LdapEntry> entries)
          Creates a new search result.
SearchResult(LdapEntry... entry)
          Creates a new search result.
SearchResult(SortBehavior sb)
          Creates a new search result.
 
Method Summary
 void addEntries(Collection<LdapEntry> entries)
          Adds entry(s) to this search result.
 void addEntry(LdapEntry... entry)
          Adds an entry to this search result.
 void addReference(SearchReference... reference)
          Adds a reference to this search result.
 void addReferences(Collection<SearchReference> references)
          Adds references(s) to this search result.
 void clear()
          Removes all the entries in this search result.
 Collection<LdapEntry> getEntries()
          Returns a collection of ldap entry.
 LdapEntry getEntry()
          Returns a single entry of this result.
 LdapEntry getEntry(String dn)
          Returns the ldap in this result with the supplied DN.
 String[] getEntryDns()
          Returns the entry DNs in this result.
 SearchReference getReference()
          Returns a single search reference of this result.
 Collection<SearchReference> getReferences()
          Returns a collection of ldap entry.
 int hashCode()
          
static SearchResult mergeEntries(SearchResult result)
          Merges the entries in the supplied result into a single entry.
 void removeEntries(Collection<LdapEntry> entries)
          Removes the entry(s) from this search result.
 void removeEntry(LdapEntry... entry)
          Removes an entry from this search result.
 void removeEntry(String dn)
          Removes the entry with the supplied dn from this search result.
 void removeReference(SearchReference... reference)
          Removes a reference from this search result.
 void removeReferences(Collection<SearchReference> references)
          Removes the references(s) from this search result.
 int size()
          Returns the number of entries in this search result.
 SearchResult subResult(int fromIndex, int toIndex)
          Returns a portion of this result between the specified fromIndex, inclusive, and toIndex, exclusive.
 String toString()
          
 
Methods inherited from class org.ldaptive.AbstractLdapBean
equals, getSortBehavior
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchResult

public SearchResult()
Default constructor.


SearchResult

public SearchResult(SortBehavior sb)
Creates a new search result.

Parameters:
sb - sort behavior of the results

SearchResult

public SearchResult(LdapEntry... entry)
Creates a new search result.

Parameters:
entry - ldap entry

SearchResult

public SearchResult(Collection<LdapEntry> entries)
Creates a new search result.

Parameters:
entries - collection of ldap entries
Method Detail

getEntries

public 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:
single entry

getEntry

public LdapEntry getEntry(String dn)
Returns the ldap in this result with the supplied DN.

Parameters:
dn - of the entry to return
Returns:
ldap entry

getEntryDns

public String[] getEntryDns()
Returns the entry DNs in this result.

Returns:
string array of entry DNs

addEntry

public void addEntry(LdapEntry... entry)
Adds an entry to this search result.

Parameters:
entry - entry to add

addEntries

public void addEntries(Collection<LdapEntry> entries)
Adds entry(s) to this search result.

Parameters:
entries - collection of entries to add

removeEntry

public void removeEntry(LdapEntry... entry)
Removes an entry from this search result.

Parameters:
entry - entry to remove

removeEntry

public void removeEntry(String dn)
Removes the entry with the supplied dn from this search result.

Parameters:
dn - of entry to remove

removeEntries

public void removeEntries(Collection<LdapEntry> entries)
Removes the entry(s) from this search result.

Parameters:
entries - collection of ldap entries to remove

getReferences

public Collection<SearchReference> getReferences()
Returns a collection of ldap entry.

Returns:
collection of ldap entry

getReference

public SearchReference 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:
single search references

addReference

public void addReference(SearchReference... reference)
Adds a reference to this search result.

Parameters:
reference - reference to add

addReferences

public void addReferences(Collection<SearchReference> references)
Adds references(s) to this search result.

Parameters:
references - collection of references to add

removeReference

public void removeReference(SearchReference... reference)
Removes a reference from this search result.

Parameters:
reference - reference to remove

removeReferences

public void removeReferences(Collection<SearchReference> references)
Removes the references(s) from this search result.

Parameters:
references - collection of search references to remove

subResult

public SearchResult 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:
IndexOutOfBoundsException - for illegal index values

size

public int size()
Returns the number of entries in this search result.

Returns:
number of entries in this search result

clear

public void clear()
Removes all the entries in this search result.


hashCode

public int hashCode()

Specified by:
hashCode in class AbstractLdapBean

toString

public String toString()

Overrides:
toString in class Object

mergeEntries

public static SearchResult mergeEntries(SearchResult 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


Copyright © 2003-2015 Virginia Tech. All Rights Reserved.