net.rim.device.api.ldap
Class LDAPComparator

java.lang.Object
  extended by net.rim.device.api.ldap.LDAPComparator
All Implemented Interfaces:
Comparator

public class LDAPComparator
extends Object
implements Comparator

Contains the functionality required for comparing LDAP objects. This object is used for sorting LDAPEntry objects according to one or many of their attributes.

Sample code

 String[] fields = new String[] {"cn","mail"};
 LDAPComparator comp = new LDAPComparator ( fields );
 String[] sortedFields = comp.getSortFields();
 

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

Constructor Summary
Category: Signed LDAPComparator(String[] sortAttributes)
          Creates an LDAPComparator object given the list of sort attributes to use.
 
Method Summary
Category: Signed  int compare(Object o1, Object o2)
          Compares two LDAPEntry objects for order.
Category: Signed  boolean equals(Object o1)
          Returns a boolean denoting whether the object passed into this method is equal to the current object.
Category: Signed  String[] getSortFields()
          Returns the attributes used to compare objects.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

LDAPComparator

public LDAPComparator(String[] sortAttributes)
Creates an LDAPComparator object given the list of sort attributes to use.

For example, to sort according to givenname followed by sn, use the following code: LDAPComparator cmp = new LDAPComparator(new String[] {"givenname","sn"});

Note that all of the attributes provided should have values that are stored as String objects. Any attributes whose values are stored as byte arrays will not be included in the comparison.

If passed an empty array of strings, all objects will be reported as equal.

Parameters:
sortFields - An array of Strings representing the sorting attributes. Must be non-null.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0


Method Detail

getSortFields

public String[] getSortFields()
Returns the attributes used to compare objects.

Returns:
An array of Strings representing the sorting attributes values.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

compare

public int compare(Object o1,
                   Object o2)
Compares two LDAPEntry objects for order.

This method compares the values of the sort attributes provided when the LDAPComparator was constructed. For each of those attributes, in order, the corresponding values are retrieved and compared, in order. When differing values are encountered, the result of the lexicographic comparison of those values is returned.

Note that any attributes whose values are stored as byte arrays will not be included in the comparison.

Specified by:
compare in interface Comparator
Parameters:
o1 - First LDAPEntry to compare.
o2 - Second LDAPEntry to compare.
Returns:
A Negative integer if the first LDAPEntry is 'less than' the second; a positive integer if the first LDAPEntry is 'greater than' the second; zero if the two LDAPEntry objects are 'equal'.
Throws:
ClassCastException - If both of the objects are not LDAPEntry objects.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

equals

public boolean equals(Object o1)
Returns a boolean denoting whether the object passed into this method is equal to the current object.

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
o1 - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Boolean.hashCode(), Hashtable
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.