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>
DECODER
A decoder which can be used for decoding the server side sort response control.static String
OID
The OID for the server-side sort response control.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAttributeDescription()
Returns the first attribute description specified in the list of sort keys that was in error, ornull
if the attribute description was not included with this control.String
getOid()
Returns the numeric OID associated with this control.ResultCode
getResult()
Returns a result code indicating the outcome of the server-side sort request.ByteString
getValue()
Returns the value, if any, associated with this control.boolean
hasValue()
Returnstrue
if this control has a value.boolean
isCritical()
Returnstrue
if it is unacceptable to perform the operation without applying the semantics of this control.static ServerSideSortResponseControl
newControl(ResultCode result)
Creates a new server-side response control with the provided sort result and no attribute description.static ServerSideSortResponseControl
newControl(ResultCode result, String attributeDescription)
Creates a new server-side response control with the provided sort result and attribute description.static ServerSideSortResponseControl
newControl(ResultCode result, AttributeDescription attributeDescription)
Creates a new server-side response control with the provided sort result and attribute description.String
toString()
-
-
-
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.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 asResultCode.NO_SUCH_ATTRIBUTE
orResultCode.INAPPROPRIATE_MATCHING
).- Returns:
- The new control.
- Throws:
NullPointerException
- Ifresult
wasnull
.
-
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 asResultCode.NO_SUCH_ATTRIBUTE
orResultCode.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
- Ifresult
wasnull
.
-
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 asResultCode.NO_SUCH_ATTRIBUTE
orResultCode.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
- IfattributeDescription
could not be parsed using the default schema.NullPointerException
- Ifresult
wasnull
.
-
getAttributeDescription
public String getAttributeDescription()
Returns the first attribute description specified in the list of sort keys that was in error, ornull
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.
-
getResult
public ResultCode getResult()
Returns a result code indicating the outcome of the server-side sort request. This will beResultCode.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 asResultCode.NO_SUCH_ATTRIBUTE
orResultCode.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.
-
hasValue
public boolean hasValue()
Description copied from interface:Control
Returnstrue
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.
-
isCritical
public boolean isCritical()
Description copied from interface:Control
Returnstrue
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 oftrue
indicates that it is unacceptable to perform the operation without applying the semantics of the control.- Specified by:
isCritical
in interfaceControl
- Returns:
true
if this control must be processed by the Directory Server, orfalse
if it can be ignored.
-
-