org.opends.server.types
Class SortKey

java.lang.Object
  extended by org.opends.server.types.SortKey

@PublicAPI(stability=VOLATILE,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class SortKey
extends java.lang.Object

This class defines a data structure that may be used as a sort key. It includes an attribute type and a boolean value that indicates whether the sort should be ascending or descending. It may also contain a specific ordering matching rule that should be used for the sorting process, although if none is provided it will use the default ordering matching rule for the attribute type.


Constructor Summary
SortKey(AttributeType attributeType, boolean ascending)
          Creates a new sort key with the provided information.
SortKey(AttributeType attributeType, boolean ascending, OrderingMatchingRule orderingRule)
          Creates a new sort key with the provided information.
 
Method Summary
 boolean ascending()
          Indicates whether the specified attribute should be sorted in ascending order.
 int compareValues(AttributeValue value1, AttributeValue value2)
          Compares the provided values using this sort key.
 boolean equals(java.lang.Object o)
          Indicates whether this sort key is equal to the provided object.
 AttributeType getAttributeType()
          Retrieves the attribute type for this sort key.
 OrderingMatchingRule getOrderingRule()
          Retrieves the ordering matching rule to use with this sort key.
 int hashCode()
          Retrieves the hash code for this sort key.
 java.lang.String toString()
          Retrieves a string representation of this sort key.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this sort key to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortKey

public SortKey(AttributeType attributeType,
               boolean ascending)
Creates a new sort key with the provided information.

Parameters:
attributeType - The attribute type for this sort key.
ascending - Indicates whether the sort should be in ascending order rather than descending.

SortKey

public SortKey(AttributeType attributeType,
               boolean ascending,
               OrderingMatchingRule orderingRule)
Creates a new sort key with the provided information.

Parameters:
attributeType - The attribute type for this sort key.
ascending - Indicates whether the sort should be in ascending order rather than descending.
orderingRule - The ordering matching rule to use with this sort key.
Method Detail

getAttributeType

public AttributeType getAttributeType()
Retrieves the attribute type for this sort key.

Returns:
The attribute type for this sort key.

ascending

public boolean ascending()
Indicates whether the specified attribute should be sorted in ascending order.

Returns:
true if the attribute should be sorted in ascending order, or false if it should be sorted in descending order.

getOrderingRule

public OrderingMatchingRule getOrderingRule()
Retrieves the ordering matching rule to use with this sort key.

Returns:
The ordering matching rule to use with this sort key.

compareValues

public int compareValues(AttributeValue value1,
                         AttributeValue value2)
Compares the provided values using this sort key.

Parameters:
value1 - The first value to be compared.
value2 - The second value to be compared.
Returns:
A negative value if the first value should come before the second in a sorted list, a positive value if the first value should come after the second in a sorted list, or zero if there is no relative difference between the values.

toString

public java.lang.String toString()
Retrieves a string representation of this sort key.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this sort key.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this sort key to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.

hashCode

public int hashCode()
Retrieves the hash code for this sort key.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this sort key.

equals

public boolean equals(java.lang.Object o)
Indicates whether this sort key is equal to the provided object.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provide object is equal to this sort key, or false if it is not.