|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.ldap.sdk.EntrySorter
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class EntrySorter
This class provides a mechanism for client-side entry sorting. Sorting may
be based on attributes contained in the entry, and may also be based on the
hierarchical location of the entry in the DIT. The sorting may be applied
to any collection of entries, including the entries included in a
SearchResult
object.
This class provides a client-side alternative to the use of the
ServerSideSortRequestControl
.
Client-side sorting is most appropriate for small result sets, as it requires
all entries to be held in memory at the same time. It is a good alternative
to server-side sorting when the overhead of sorting should be distributed
across client systems rather than on the server, and in cases in which the
target directory server does not support the use of the server-side sort
request control.
For best results, a Schema
object may be used to provide an
indication as to which matching rules should be used to perform the ordering.
If no Schema
object is provided, then all ordering will be performed
using case-ignore string matching.
SearchResult searchResult = connection.search("dc=example,dc=com", SearchScope.SUB, Filter.createEqualityFilter("sn", "Smith")); EntrySorter entrySorter = new EntrySorter(false, new SortKey("sn"), new SortKey("givenName")); SortedSet<Entry> sortedEntries = entrySorter.sort(searchResult.getSearchEntries());
Constructor Summary | |
---|---|
EntrySorter()
Creates a new entry sorter that will sort entries based only on hierarchy. |
|
EntrySorter(boolean sortByHierarchy,
java.util.List<SortKey> sortKeys)
Creates a new entry sorter with the provided information. |
|
EntrySorter(boolean sortByHierarchy,
Schema schema,
java.util.List<SortKey> sortKeys)
Creates a new entry sorter with the provided information. |
|
EntrySorter(boolean sortByHierarchy,
Schema schema,
SortKey... sortKeys)
Creates a new entry sorter with the provided information. |
|
EntrySorter(boolean sortByHierarchy,
SortKey... sortKeys)
Creates a new entry sorter with the provided information. |
Method Summary | |
---|---|
int |
compare(Entry e1,
Entry e2)
Compares the provided entries to determine the order in which they should be placed in a sorted list. |
boolean |
equals(java.lang.Object o)
Indicates whether the provided object is equal to this entry sorter. |
int |
hashCode()
Retrieves a hash code for this entry sorter. |
java.util.SortedSet<Entry> |
sort(java.util.Collection<? extends Entry> entries)
Sorts the provided collection of entries according to the criteria defined in this entry sorter. |
java.lang.String |
toString()
Retrieves a string representation of this entry sorter. |
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this entry sorter to the provided buffer. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EntrySorter()
public EntrySorter(boolean sortByHierarchy, SortKey... sortKeys)
sortByHierarchy
- Indicates whether entries should be sorted
hierarchically, such that superior entries will
be ordered before subordinate entries.sortKeys
- A list of sort keys that define the order in which
attributes should be compared. It may be empty
(but never null
) if sorting should be done
only based on hierarchy.public EntrySorter(boolean sortByHierarchy, Schema schema, SortKey... sortKeys)
sortByHierarchy
- Indicates whether entries should be sorted
hierarchically, such that superior entries will
be ordered before subordinate entries.schema
- The schema to use to make the determination. It
may be null
if no schema is available.sortKeys
- A list of sort keys that define the order in which
attributes should be compared. It may be empty
(but never null
) if sorting should be done
only based on hierarchy.public EntrySorter(boolean sortByHierarchy, java.util.List<SortKey> sortKeys)
sortByHierarchy
- Indicates whether entries should be sorted
hierarchically, such that superior entries will
be ordered before subordinate entries.sortKeys
- A list of sort keys that define the order in which
attributes should be compared. It may be empty or
null
if sorting should be done only based
on hierarchy.public EntrySorter(boolean sortByHierarchy, Schema schema, java.util.List<SortKey> sortKeys)
sortByHierarchy
- Indicates whether entries should be sorted
hierarchically, such that superior entries will
be ordered before subordinate entries.schema
- The schema to use to make the determination. It
may be null
if no schema is available.sortKeys
- A list of sort keys that define the order in which
attributes should be compared. It may be empty or
null
if sorting should be done only based
on hierarchy.Method Detail |
---|
public java.util.SortedSet<Entry> sort(java.util.Collection<? extends Entry> entries)
entries
- The collection of entries to be sorted.
public int compare(Entry e1, Entry e2)
compare
in interface java.util.Comparator<Entry>
e1
- The first entry to be compared.e2
- The second entry to be compared.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in interface java.util.Comparator<Entry>
equals
in class java.lang.Object
o
- The object for which to make the determination.
true
if the provided object is equal to this entry sorter,
or false
if not.public java.lang.String toString()
toString
in class java.lang.Object
public void toString(java.lang.StringBuilder buffer)
buffer
- The buffer to which the string representation should be
appended.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |