Class LDAPCompareAttrNames
- All Implemented Interfaces:
Serializable
,LDAPEntryComparator
To use this comparison for sorting search results, pass
an object of this class to the sort
method in
LDAPSearchResults
.
- Version:
- 1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLDAPCompareAttrNames
(String attribute) Constructs a comparator that compares the string values of a named attribute in LDAP entries and sorts the entries in ascending order.LDAPCompareAttrNames
(String[] attributes) Constructs a comparator that compares the string values of a set of named attributes in LDAP entries and that sort the entries in ascending order.LDAPCompareAttrNames
(String[] attributes, boolean[] ascendingFlags) Constructs a comparator that compares the string values of a set of named attributes in LDAP entries and allows you to sort the entries in ascending or descending order.LDAPCompareAttrNames
(String attribute, boolean ascendingFlag) Constructs a comparator that compares the string values of a named attribute in LDAP entries and that allows you to sort entries either in ascending or descending order. -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
attrGreater
(LDAPEntry greater, LDAPEntry less, int attrPos) Compares a particular attribute in both entries.boolean
Gets the state of the case-sensitivity flag.Gets the locale, if any, used for collation.boolean
Returnstrue
if the value of the attribute in the first entry is greater than the value of the attribute in the second entry.void
setCaseSensitive
(boolean sensitive) Sets the state of the case-sensitivity flag.void
Set the locale, if any, used for collation.void
Sets the locale, if any, used for collation.
-
Field Details
-
serialVersionUID
static final long serialVersionUID- See Also:
-
m_attrs
-
m_ascending
private boolean[] m_ascending -
m_locale
-
m_collator
-
m_sensitive
private boolean m_sensitive
-
-
Constructor Details
-
LDAPCompareAttrNames
Constructs a comparator that compares the string values of a named attribute in LDAP entries and sorts the entries in ascending order.- Parameters:
attribute
- name of attribute for comparisons
-
LDAPCompareAttrNames
Constructs a comparator that compares the string values of a named attribute in LDAP entries and that allows you to sort entries either in ascending or descending order.- Parameters:
attribute
- name of attribute for comparisonsascendingFlag
- iftrue
, sort in ascending order
-
LDAPCompareAttrNames
Constructs a comparator that compares the string values of a set of named attributes in LDAP entries and that sort the entries in ascending order.Use an array of strings to specify the set of attributes to use for sorting. If the values of the first attribute (the name specified in
attribute[0]
) are equal, then the values of the next attribute are compared.For example, if
attributes[0] = "cn"
andattributes[1]="uid"
, results are first sorted by thecn
attribute. If two entries have the same value forcn
, then theuid
attribute is used to sort the entries.- Parameters:
attributes
- array of the attribute names used for comparisons
-
LDAPCompareAttrNames
Constructs a comparator that compares the string values of a set of named attributes in LDAP entries and allows you to sort the entries in ascending or descending order.Use an array of strings to specify the set of attributes to use for sorting. If the values of the first attribute (the name specified in
attribute[0]
) are equal, then the values of the next attribute are compared.For example, if
attributes[0] = "cn"
andattributes[1]="uid"
, results are first sorted by thecn
attribute. If two entries have the same value forcn
, then theuid
attribute is used to sort the entries.Use an array of boolean values to specify whether each attribute should be sorted in ascending or descending order. For example, suppose that
attributes[0] = "cn"
andattributes[1]="roomNumber"
. IfascendingFlags[0]=true
andascendingFlags[1]=false
, attributes are sorted first bycn
in ascending order, then byroomNumber
in descending order.If the size of the array of attribute names is not the same as the size of the array of boolean values, an
LDAPException
is thrown.- Parameters:
attributes
- array of the attribute names to use for comparisonsascendingFlags
- array of boolean values specifying ascending or descending order to use for each attribute name. Iftrue
, the attributes are sorted in ascending order.
-
-
Method Details
-
getLocale
Gets the locale, if any, used for collation. If the locale is null, an ordinary string comparison is used for sorting.- Returns:
- the locale used for collation, or null.
-
setLocale
Set the locale, if any, used for collation. If the locale is null, an ordinary string comparison is used for sorting. If sorting has been set to case-insensitive, the collation strength is set to Collator.PRIMARY, otherwise to Collator.IDENTICAL. If a different collation strength setting is required, use the signature that takes a collation strength parameter.- Parameters:
locale
- the locale used for collation, or null.
-
setLocale
Sets the locale, if any, used for collation. If the locale is null, an ordinary string comparison is used for sorting.- Parameters:
locale
- the locale used for collation, or null.strength
- collation strength: Collator.PRIMARY, Collator.SECONDARY, Collator.TERTIARY, or Collator.IDENTICAL
-
getCaseSensitive
public boolean getCaseSensitive()Gets the state of the case-sensitivity flag. This only applies to Unicode sort order; for locale-specific sorting, case-sensitivity is controlled by the collation strength.- Returns:
true
for case-sensitive sorting; this is the default
-
setCaseSensitive
public void setCaseSensitive(boolean sensitive) Sets the state of the case-sensitivity flag. This only applies to Unicode sort order; for locale-specific sorting, case-sensitivity is controlled by the collation strength.- Parameters:
sensitive
-true
for case-sensitive sorting; this is the default
-
isGreater
Returnstrue
if the value of the attribute in the first entry is greater than the value of the attribute in the second entry.If one of the entries is missing the attribute, the other is considered greater. By default, the first entry is greater.
If either entry contains multiple values, only the first value is used for comparisons.
- Specified by:
isGreater
in interfaceLDAPEntryComparator
- Parameters:
greater
- entry against which to testless
- entry to test- Returns:
true
if (greater > less
).- See Also:
-
attrGreater
Compares a particular attribute in both entries. If equal, moves on to the next.- Parameters:
greater
- greater arg from isGreaterless
- less arg from isGreaterattrPos
- the index in an array of attributes, indicating the attribute to compare- Returns:
- (greater > less)
-