SHOW Signed

net.rim.device.api.ldap
Class LDAPComparator

java.lang.Object
  |
  +--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.

Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.

Since:
JDE 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.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Method Detail

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.

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.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.

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
Since:
JDE 4.0.0

Following copied from interface: Comparator
Parameters:
obj - Object to compare with this comparator.
Returns:
True if your provided object is also a comparator and imposes the same ordering as this comparator.
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.

getSortFields

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

Returns:
An array of Strings representing the sorting attributes values.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.


Copyright 1999-2007 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.