Class ServerSideSortResponseControl

java.lang.Object
org.forgerock.opendj.ldap.controls.ServerSideSortResponseControl
All Implemented Interfaces:
Control

public final class ServerSideSortResponseControl extends Object implements Control
The server-side sort response control as defined in RFC 2891. This control is included with a search result in response to a server-side sort request included with a search request. The client application is assured that the search results are sorted in the specified key order if and only if the result code in this control is success. If the server omits this control from the search result, the client SHOULD assume that the sort control was ignored by the server.

The following example demonstrates how to work with a server-side sort.

 
 Connection connection = ...;

 SearchRequest request = Requests.newSearchRequest(
         "ou=People,dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(sn=Jensen)", "cn")
         .addControl(ServerSideSortRequestControl.newControl(true, new SortKey("cn")));

 SearchResultHandler resultHandler = new MySearchResultHandler();
 Result result = connection.search(request, resultHandler);

 ServerSideSortResponseControl control = result.getControl(
         ServerSideSortResponseControl.DECODER, new DecodeOptions());
 if (control != null && control.getResult() == ResultCode.SUCCESS) {
     // Entries are sorted.
 } else {
     // Entries not sorted.
 }
 
 
See Also:
  • Field Details

  • Method Details

    • newControl

      public static ServerSideSortResponseControl newControl(ResultCode result)
      Creates a new server-side response control with the provided sort result and no attribute description.
      Parameters:
      result - The result code indicating the outcome of the server-side sort request. ResultCode.SUCCESS if the search results were sorted in accordance with the keys specified in the server-side sort request control, or an error code indicating why the results could not be sorted (such as ResultCode.NO_SUCH_ATTRIBUTE or ResultCode.INAPPROPRIATE_MATCHING).
      Returns:
      The new control.
      Throws:
      NullPointerException - If result was null.
    • newControl

      public static ServerSideSortResponseControl newControl(ResultCode result, AttributeDescription attributeDescription)
      Creates a new server-side response control with the provided sort result and attribute description.
      Parameters:
      result - The result code indicating the outcome of the server-side sort request. ResultCode.SUCCESS if the search results were sorted in accordance with the keys specified in the server-side sort request control, or an error code indicating why the results could not be sorted (such as ResultCode.NO_SUCH_ATTRIBUTE or ResultCode.INAPPROPRIATE_MATCHING).
      attributeDescription - The first attribute description specified in the list of sort keys that was in error, may be null.
      Returns:
      The new control.
      Throws:
      NullPointerException - If result was null.
    • newControl

      public static ServerSideSortResponseControl newControl(ResultCode result, String attributeDescription)
      Creates a new server-side response control with the provided sort result and attribute description. The attribute description will be decoded using the default schema.
      Parameters:
      result - The result code indicating the outcome of the server-side sort request. ResultCode.SUCCESS if the search results were sorted in accordance with the keys specified in the server-side sort request control, or an error code indicating why the results could not be sorted (such as ResultCode.NO_SUCH_ATTRIBUTE or ResultCode.INAPPROPRIATE_MATCHING).
      attributeDescription - The first attribute description specified in the list of sort keys that was in error, may be null.
      Returns:
      The new control.
      Throws:
      LocalizedIllegalArgumentException - If attributeDescription could not be parsed using the default schema.
      NullPointerException - If result was null.
    • getAttributeDescription

      public String getAttributeDescription()
      Returns the first attribute description specified in the list of sort keys that was in error, or null if the attribute description was not included with this control.
      Returns:
      The first attribute description specified in the list of sort keys that was in error.
    • getOid

      public String getOid()
      Description copied from interface: Control
      Returns the numeric OID associated with this control.
      Specified by:
      getOid in interface Control
      Returns:
      the numeric OID associated with this control
    • getResult

      public ResultCode getResult()
      Returns a result code indicating the outcome of the server-side sort request. This will be ResultCode.SUCCESS if the search results were sorted in accordance with the keys specified in the server-side sort request control, or an error code indicating why the results could not be sorted (such as ResultCode.NO_SUCH_ATTRIBUTE or ResultCode.INAPPROPRIATE_MATCHING).
      Returns:
      The result code indicating the outcome of the server-side sort request.
    • getValue

      public ByteString getValue()
      Description copied from interface: Control
      Returns the value, if any, associated with this control. Its format is defined by the specification of this control.
      Specified by:
      getValue in interface Control
      Returns:
      The value associated with this control, or null if there is no value.
    • hasValue

      public boolean hasValue()
      Description copied from interface: Control
      Returns true if this control has a value. In some circumstances it may be useful to determine if a control has a value, without actually calculating the value and incurring any performance costs.
      Specified by:
      hasValue in interface Control
      Returns:
      true if this control has a value, or false if there is no value.
    • isCritical

      public boolean isCritical()
      Description copied from interface: Control
      Returns true if it is unacceptable to perform the operation without applying the semantics of this control.

      The criticality field only has meaning in controls attached to request messages (except UnbindRequest). For controls attached to response messages and the UnbindRequest, the criticality field SHOULD be false, and MUST be ignored by the receiving protocol peer. A value of true indicates that it is unacceptable to perform the operation without applying the semantics of the control.

      Specified by:
      isCritical in interface Control
      Returns:
      true if this control must be processed by the Directory Server, or false if it can be ignored.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAlias

      public String getAlias()
      Description copied from interface: Control
      Returns the control "friendly name" alias for the control.
      Specified by:
      getAlias in interface Control
      Returns:
      "Friendly name" alias for the control.