public final class ServerSideSortRequestControl extends Object implements Control
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 SortKey
for 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.
}
Modifier and Type | Field and Description |
---|---|
static ControlDecoder<ServerSideSortRequestControl> |
DECODER
A decoder which can be used for decoding the server side sort request control.
|
static String |
OID
The OID for the server-side sort request control.
|
Modifier and Type | Method and Description |
---|---|
String |
getOid()
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.
|
ByteString |
getValue()
Returns the value, if any, associated with this control.
|
boolean |
hasValue()
Returns
true if this control has a value. |
boolean |
isCritical()
Returns
true if it is unacceptable to perform the operation
without applying the semantics of this control. |
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.
|
static ServerSideSortRequestControl |
newControl(boolean isCritical,
SortKey... keys)
Creates a new server side sort request control with the provided
criticality and list of sort keys.
|
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.
|
String |
toString() |
public static final String OID
public static final ControlDecoder<ServerSideSortRequestControl> DECODER
public static ServerSideSortRequestControl newControl(boolean isCritical, Collection<SortKey> keys)
isCritical
- true
if it is unacceptable to perform the operation
without applying the semantics of this control, or
false
if it can be ignored.keys
- The list of sort keys.IllegalArgumentException
- If keys
was empty.NullPointerException
- If keys
was null
.public static ServerSideSortRequestControl newControl(boolean isCritical, SortKey... keys)
isCritical
- true
if it is unacceptable to perform the operation
without applying the semantics of this control, or
false
if it can be ignored.keys
- The list of sort keys.IllegalArgumentException
- If keys
was empty.NullPointerException
- If keys
was null
.public static ServerSideSortRequestControl newControl(boolean isCritical, String sortKeys)
SortKey.valueOf(String)
. There must be at least one
sort key present in the string representation.isCritical
- true
if it is unacceptable to perform the operation
without applying the semantics of this control, or
false
if it can be ignored.sortKeys
- The list of sort keys.org.forgerock.i18n.LocalizedIllegalArgumentException
- If sortKeys
is not a valid string representation of a
list of sort keys.NullPointerException
- If sortKeys
was null
.public String getOid()
Control
public List<SortKey> getSortKeys()
public ByteString getValue()
Control
public boolean hasValue()
Control
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.public boolean isCritical()
Control
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.
isCritical
in interface Control
true
if this control must be processed by the Directory
Server, or false
if it can be ignored.Copyright 2011-2017 ForgeRock AS.