All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.novell.ldap.controls.LDAPSortControl Maven / Gradle / Ivy

There is a newer version: 2009-10-07
Show newest version
/* **************************************************************************
 * $OpenLDAP: pkg/jldap/com/novell/ldap/controls/LDAPSortControl.java,v 1.15 2004/01/16 05:08:09 sunilk Exp $
 *
 * Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
 *
 * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
 * TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
 * TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
 * AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
 * IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
 * OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
 * PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
 ******************************************************************************/

package com.novell.ldap.controls;

import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.client.Debug;

/**
 *  LDAPSortControl is a Server Control to specify how search results are
 *  to be sorted by the server. If a server does not support
 *  sorting in general or for a particular query, the results will be
 *  returned unsorted, along with a control indicating why they were not
 *  sorted (or that sort controls are not supported). If the control was
 *  marked "critical", the whole search operation will fail if the sort
 *  control is not supported.
 *
 * 

Sample Code: AsyncSortControl.java

*/ public class LDAPSortControl extends LDAPControl { private static int ORDERING_RULE = 0; private static int REVERSE_ORDER = 1; /** * The requestOID of the sort control */ private static String requestOID = "1.2.840.113556.1.4.473"; /** * The responseOID of the sort control */ private static String responseOID = "1.2.840.113556.1.4.474"; /* * This is where we register the control responses */ static { /* * Register the Server Sort Control class which is returned by the * server in response to a Sort Request */ try { LDAPControl.register(responseOID, Class.forName("com.novell.ldap.controls.LDAPSortResponse")); if( Debug.LDAP_DEBUG) { Debug.trace( Debug.controls, "Registered Sort Control Response Class"); } } catch (ClassNotFoundException e) { if( Debug.LDAP_DEBUG) { Debug.trace( Debug.controls, "Could not register Sort Control Response - Class not found"); } } } /** * Constructs a sort control with a single key. * * @param key A sort key object, which specifies attribute, * order, and optional matching rule. * * @param critical True if the search operation is to fail if the * server does not support this control. */ public LDAPSortControl(LDAPSortKey key, boolean critical) { this(new LDAPSortKey[]{key}, critical); return; } /** * Constructs a sort control with multiple sort keys. * * @param keys An array of sort key objects, to be processed in * order. * * @param critical True if the search operation is to fail if the * server does not support this control. */ public LDAPSortControl(LDAPSortKey[] keys, boolean critical) { super(requestOID, critical, null); ASN1SequenceOf sortKeyList = new ASN1SequenceOf(); for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy