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. }
-
-
Field Summary
Fields Modifier and Type Field Description static ControlDecoder<ServerSideSortResponseControl>DECODERA decoder which can be used for decoding the server side sort response control.static StringOIDThe OID for the server-side sort response control.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAttributeDescription()Returns the first attribute description specified in the list of sort keys that was in error, ornullif the attribute description was not included with this control.StringgetOid()Returns the numeric OID associated with this control.ResultCodegetResult()Returns a result code indicating the outcome of the server-side sort request.ByteStringgetValue()Returns the value, if any, associated with this control.booleanhasValue()Returnstrueif this control has a value.booleanisCritical()Returnstrueif it is unacceptable to perform the operation without applying the semantics of this control.static ServerSideSortResponseControlnewControl(ResultCode result)Creates a new server-side response control with the provided sort result and no attribute description.static ServerSideSortResponseControlnewControl(ResultCode result, String attributeDescription)Creates a new server-side response control with the provided sort result and attribute description.static ServerSideSortResponseControlnewControl(ResultCode result, AttributeDescription attributeDescription)Creates a new server-side response control with the provided sort result and attribute description.StringtoString()
-
-
-
Field Detail
-
OID
public static final String OID
The OID for the server-side sort response control.- See Also:
- Constant Field Values
-
DECODER
public static final ControlDecoder<ServerSideSortResponseControl> DECODER
A decoder which can be used for decoding the server side sort response control.
-
-
Method Detail
-
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.SUCCESSif 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 asResultCode.NO_SUCH_ATTRIBUTEorResultCode.INAPPROPRIATE_MATCHING).- Returns:
- The new control.
- Throws:
NullPointerException- Ifresultwasnull.
-
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.SUCCESSif 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 asResultCode.NO_SUCH_ATTRIBUTEorResultCode.INAPPROPRIATE_MATCHING).attributeDescription- The first attribute description specified in the list of sort keys that was in error, may benull.- Returns:
- The new control.
- Throws:
NullPointerException- Ifresultwasnull.
-
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.SUCCESSif 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 asResultCode.NO_SUCH_ATTRIBUTEorResultCode.INAPPROPRIATE_MATCHING).attributeDescription- The first attribute description specified in the list of sort keys that was in error, may benull.- Returns:
- The new control.
- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be parsed using the default schema.NullPointerException- Ifresultwasnull.
-
getAttributeDescription
public String getAttributeDescription()
Returns the first attribute description specified in the list of sort keys that was in error, ornullif 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:ControlReturns 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 beResultCode.SUCCESSif 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 asResultCode.NO_SUCH_ATTRIBUTEorResultCode.INAPPROPRIATE_MATCHING).- Returns:
- The result code indicating the outcome of the server-side sort request.
-
getValue
public ByteString getValue()
Description copied from interface:ControlReturns the value, if any, associated with this control. Its format is defined by the specification of this control.
-
hasValue
public boolean hasValue()
Description copied from interface:ControlReturnstrueif 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.
-
isCritical
public boolean isCritical()
Description copied from interface:ControlReturnstrueif 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 oftrueindicates that it is unacceptable to perform the operation without applying the semantics of the control.- Specified by:
isCriticalin interfaceControl- Returns:
trueif this control must be processed by the Directory Server, orfalseif it can be ignored.
-
-