Class ServerSideSortRequestControl
- java.lang.Object
-
- org.forgerock.opendj.ldap.controls.ServerSideSortRequestControl
-
- All Implemented Interfaces:
Control
public final class ServerSideSortRequestControl extends Object implements Control
The server-side sort request control as defined in RFC 2891. This control may be included in a search request to indicate that search result entries should be sorted by the server before being returned. The sort order is specified using one or more sort keys, the first being the primary key, and so on.This controls may be useful when the client has limited functionality or for some other reason cannot sort the results but still needs them sorted. In cases where the client can sort the results client-side sorting is recommended in order to reduce load on the server. See
SortKeyfor an example of client-side sorting.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<ServerSideSortRequestControl>DECODERA decoder which can be used for decoding the server side sort request control.static StringOIDThe OID for the server-side sort request control.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetOid()Returns the numeric OID associated with this control.List<SortKey>getSortKeys()Returns an unmodifiable list containing the sort keys associated with this server side sort request control.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 ServerSideSortRequestControlnewControl(boolean isCritical, String sortKeys)Creates a new server side sort request control with the provided criticality and string representation of a list of sort keys.static ServerSideSortRequestControlnewControl(boolean isCritical, Collection<SortKey> keys)Creates a new server side sort request control with the provided criticality and list of sort keys.static ServerSideSortRequestControlnewControl(boolean isCritical, SortKey... keys)Creates a new server side sort request control with the provided criticality and list of sort keys.StringtoString()
-
-
-
Field Detail
-
OID
public static final String OID
The OID for the server-side sort request control.- See Also:
- Constant Field Values
-
DECODER
public static final ControlDecoder<ServerSideSortRequestControl> DECODER
A decoder which can be used for decoding the server side sort request control.
-
-
Method Detail
-
newControl
public static ServerSideSortRequestControl newControl(boolean isCritical, Collection<SortKey> keys)
Creates a new server side sort request control with the provided criticality and list of sort keys.- Parameters:
isCritical-trueif it is unacceptable to perform the operation without applying the semantics of this control, orfalseif it can be ignored.keys- The list of sort keys.- Returns:
- The new control.
- Throws:
IllegalArgumentException- Ifkeyswas empty.NullPointerException- Ifkeyswasnull.
-
newControl
public static ServerSideSortRequestControl newControl(boolean isCritical, SortKey... keys)
Creates a new server side sort request control with the provided criticality and list of sort keys.- Parameters:
isCritical-trueif it is unacceptable to perform the operation without applying the semantics of this control, orfalseif it can be ignored.keys- The list of sort keys.- Returns:
- The new control.
- Throws:
IllegalArgumentException- Ifkeyswas empty.NullPointerException- Ifkeyswasnull.
-
newControl
public static ServerSideSortRequestControl newControl(boolean isCritical, String sortKeys)
Creates a new server side sort request control with the provided criticality and string representation of a list of sort keys. The string representation is comprised of a comma separate list of sort keys as defined inSortKey.valueOf(String). There must be at least one sort key present in the string representation.- Parameters:
isCritical-trueif it is unacceptable to perform the operation without applying the semantics of this control, orfalseif it can be ignored.sortKeys- The list of sort keys.- Returns:
- The new control.
- Throws:
LocalizedIllegalArgumentException- IfsortKeysis not a valid string representation of a list of sort keys.NullPointerException- IfsortKeyswasnull.
-
getOid
public String getOid()
Description copied from interface:ControlReturns the numeric OID associated with this control.
-
getSortKeys
public List<SortKey> getSortKeys()
Returns an unmodifiable list containing the sort keys associated with this server side sort request control. The list will contain at least one sort key.- Returns:
- An unmodifiable list containing the sort keys associated with this server side sort request control.
-
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.
-
-