Class SortKey

java.lang.Object
com.unboundid.ldap.sdk.controls.SortKey
All Implemented Interfaces:
Serializable

This class provides a data structure for representing a sort key that is to be used in conjunction with the ServerSideSortRequestControl for requesting that the server sort the results before returning them to the client.

A sort key includes the following elements:
  • The name of the attribute for which sorting is to be performed.
  • A reverseOrder flag that indicates whether the results should be sorted in ascending order (if the value is false) or descending order (if the value is true).
  • An optional matching rule ID, which specifies the ordering matching rule that should be used to perform the sorting. If this is not provided, then the default ordering matching rule for the specified attribute will be used.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    SortKey(String attributeName)
    Creates a new sort key with the specified attribute name.
    SortKey(String attributeName, boolean reverseOrder)
    Creates a new sort key with the specified attribute name.
    SortKey(String attributeName, String matchingRuleID, boolean reverseOrder)
    Creates a new sort key with the provided information.
  • Method Summary

    Modifier and Type
    Method
    Description
    static SortKey
    Decodes the provided ASN.1 element as a sort key.
    Retrieves the attribute name for this sort key.
    Retrieves the name or OID of the ordering matching rule that should be used to perform the sort, if defined.
    boolean
    Indicates whether the sort should be performed in reverse order.
    Retrieves a string representation of this sort key.
    void
    Appends a string representation of this sort key to the provided buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SortKey

      public SortKey(@NotNull String attributeName)
      Creates a new sort key with the specified attribute name. It will use the default ordering matching rule associated with that attribute, and it will not use reverse order.
      Parameters:
      attributeName - The attribute name for this sort key. It must not be null.
    • SortKey

      public SortKey(@NotNull String attributeName, boolean reverseOrder)
      Creates a new sort key with the specified attribute name. It will use the default ordering matching rule associated with that attribute.
      Parameters:
      attributeName - The attribute name for this sort key. It must not be null.
      reverseOrder - Indicates whether the sort should be performed in reverse order.
    • SortKey

      public SortKey(@NotNull String attributeName, @Nullable String matchingRuleID, boolean reverseOrder)
      Creates a new sort key with the provided information.
      Parameters:
      attributeName - The attribute name for this sort key. It must not be null.
      matchingRuleID - The name or OID of the ordering matching rule that should be used to perform the sort. It may be null if the default ordering matching rule for the specified attribute is to be used.
      reverseOrder - Indicates whether the sort should be performed in reverse order.
  • Method Details

    • getAttributeName

      Retrieves the attribute name for this sort key.
      Returns:
      The attribute name for this sort key.
    • getMatchingRuleID

      Retrieves the name or OID of the ordering matching rule that should be used to perform the sort, if defined.
      Returns:
      The name or OID of the ordering matching rule that should be used to perform the sort, or null if the sort should use the default ordering matching rule associated with the specified attribute.
    • reverseOrder

      public boolean reverseOrder()
      Indicates whether the sort should be performed in reverse order.
      Returns:
      true if the sort should be performed in reverse order, or false if it should be performed in the standard order for the associated ordering matching rule.
    • decode

      @NotNull public static SortKey decode(@NotNull ASN1Element element) throws LDAPException
      Decodes the provided ASN.1 element as a sort key.
      Parameters:
      element - The ASN.1 element to decode as a sort key.
      Returns:
      The decoded sort key.
      Throws:
      LDAPException - If the provided ASN.1 element cannot be decoded as a sort key.
    • toString

      Retrieves a string representation of this sort key.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this sort key.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of this sort key to the provided buffer.
      Parameters:
      buffer - The buffer to which to append a string representation of this sort key.