19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.naming.ldap;
27
28 import java.io.IOException;
29 import com.sun.jndi.ldap.Ber;
30 import com.sun.jndi.ldap.BerEncoder;
31
32 /**
33 * Requests that the results of a search operation be returned by the LDAP
34 * server in batches of a specified size.
35 * The requestor controls the rate at which batches are returned by the rate
36 * at which it invokes search operations.
37 * <p>
38 * The following code sample shows how the class may be used:
39 * <pre>
40 *
41 * // Open an LDAP association
42 * LdapContext ctx = new InitialLdapContext();
43 *
44 * // Activate paged results
45 * int pageSize = 20; // 20 entries per page
46 * byte[] cookie = null;
47 * int total;
48 * ctx.setRequestControls(new Control[]{
49 * new PagedResultsControl(pageSize, Control.CRITICAL) });
50 *
51 * do {
52 * // Perform the search
53 * NamingEnumeration results =
54 * ctx.search("", "(objectclass=*)", new SearchControls());
55 *
56 * // Iterate over a batch of search results
57 * while (results != null && results.hasMore()) {
58 * // Display an entry
59 * SearchResult entry = (SearchResult)results.next();
72 * if (controls[i] instanceof PagedResultsResponseControl) {
73 * PagedResultsResponseControl prrc =
74 * (PagedResultsResponseControl)controls[i];
75 * total = prrc.getResultSize();
76 * cookie = prrc.getCookie();
77 * } else {
78 * // Handle other response controls (if any)
79 * }
80 * }
81 * }
82 *
83 * // Re-activate paged results
84 * ctx.setRequestControls(new Control[]{
85 * new PagedResultsControl(pageSize, cookie, Control.CRITICAL) });
86 * } while (cookie != null);
87 *
88 * // Close the LDAP association
89 * ctx.close();
90 * ...
91 *
92 * </pre>
93 * <p>
94 * This class implements the LDAPv3 Control for paged-results as defined in
95 * <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
96 *
97 * The control's value has the following ASN.1 definition:
98 * <pre>
99 *
100 * realSearchControlValue ::= SEQUENCE {
101 * size INTEGER (0..maxInt),
102 * -- requested page size from client
103 * -- result set size estimate from server
104 * cookie OCTET STRING
105 * }
106 *
107 * </pre>
108 *
109 * @since 1.5
110 * @see PagedResultsResponseControl
111 * @author Vincent Ryan
112 */
113 final public class PagedResultsControl extends BasicControl {
114
115 /**
116 * The paged-results control's assigned object identifier
117 * is 1.2.840.113556.1.4.319.
118 */
119 public static final String OID = "1.2.840.113556.1.4.319";
120
121 private static final byte[] EMPTY_COOKIE = new byte[0];
122
123 private static final long serialVersionUID = 6684806685736844298L;
124
125 /**
126 * Constructs a control to set the number of entries to be returned per
127 * page of results.
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javax.naming.ldap;
27
28 import java.io.IOException;
29 import com.sun.jndi.ldap.Ber;
30 import com.sun.jndi.ldap.BerEncoder;
31
32 /**
33 * Requests that the results of a search operation be returned by the LDAP
34 * server in batches of a specified size.
35 * The requestor controls the rate at which batches are returned by the rate
36 * at which it invokes search operations.
37 * <p>
38 * The following code sample shows how the class may be used:
39 * <pre>{@code
40 *
41 * // Open an LDAP association
42 * LdapContext ctx = new InitialLdapContext();
43 *
44 * // Activate paged results
45 * int pageSize = 20; // 20 entries per page
46 * byte[] cookie = null;
47 * int total;
48 * ctx.setRequestControls(new Control[]{
49 * new PagedResultsControl(pageSize, Control.CRITICAL) });
50 *
51 * do {
52 * // Perform the search
53 * NamingEnumeration results =
54 * ctx.search("", "(objectclass=*)", new SearchControls());
55 *
56 * // Iterate over a batch of search results
57 * while (results != null && results.hasMore()) {
58 * // Display an entry
59 * SearchResult entry = (SearchResult)results.next();
72 * if (controls[i] instanceof PagedResultsResponseControl) {
73 * PagedResultsResponseControl prrc =
74 * (PagedResultsResponseControl)controls[i];
75 * total = prrc.getResultSize();
76 * cookie = prrc.getCookie();
77 * } else {
78 * // Handle other response controls (if any)
79 * }
80 * }
81 * }
82 *
83 * // Re-activate paged results
84 * ctx.setRequestControls(new Control[]{
85 * new PagedResultsControl(pageSize, cookie, Control.CRITICAL) });
86 * } while (cookie != null);
87 *
88 * // Close the LDAP association
89 * ctx.close();
90 * ...
91 *
92 * } </pre>
93 * <p>
94 * This class implements the LDAPv3 Control for paged-results as defined in
95 * <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
96 *
97 * The control's value has the following ASN.1 definition:
98 * <pre>{@code
99 *
100 * realSearchControlValue ::= SEQUENCE {
101 * size INTEGER (0..maxInt),
102 * -- requested page size from client
103 * -- result set size estimate from server
104 * cookie OCTET STRING
105 * }
106 *
107 * }</pre>
108 *
109 * @since 1.5
110 * @see PagedResultsResponseControl
111 * @author Vincent Ryan
112 */
113 final public class PagedResultsControl extends BasicControl {
114
115 /**
116 * The paged-results control's assigned object identifier
117 * is 1.2.840.113556.1.4.319.
118 */
119 public static final String OID = "1.2.840.113556.1.4.319";
120
121 private static final byte[] EMPTY_COOKIE = new byte[0];
122
123 private static final long serialVersionUID = 6684806685736844298L;
124
125 /**
126 * Constructs a control to set the number of entries to be returned per
127 * page of results.
|