| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.naming.ldap.BasicControl
javax.naming.ldap.PagedResultsControl
public final class PagedResultsControl
请求由 LDAP 服务器以指定的大小批量返回搜索操作的结果。请求方根据搜索操作调用率控制批量返回率。
以下代码示例展示了使用该类的方式:
     // Open an LDAP association
     LdapContext ctx = new InitialLdapContext();
     // Activate paged results
     int pageSize = 20; // 20 entries per page
     byte[] cookie = null;
     int total;
     ctx.setRequestControls(new Control[]{ 
         new PagedResultsControl(pageSize, Control.CRITICAL) });
     do {
         // Perform the search
         NamingEnumeration results =
             ctx.search("", "(objectclass=*)", new SearchControls());
         // Iterate over a batch of search results
         while (results != null && results.hasMore()) {
             // Display an entry
             SearchResult entry = (SearchResult)results.next();
             System.out.println(entry.getName());
             System.out.println(entry.getAttributes());
             // Handle the entry's response controls (if any)
             if (entry instanceof HasControls) {
                 // ((HasControls)entry).getControls();
             }
         }
         // Examine the paged results control response 
         Control[] controls = ctx.getResponseControls();
         if (controls != null) {
             for (int i = 0; i < controls.length; i++) {
                 if (controls[i] instanceof PagedResultsResponseControl) {
                     PagedResultsResponseControl prrc =
                         (PagedResultsResponseControl)controls[i];
                     total = prrc.getResultSize();
                     cookie = prrc.getCookie();
                 } else {
                     // Handle other response controls (if any)
                 }
             }
         }
         // Re-activate paged results
         ctx.setRequestControls(new Control[]{
             new PagedResultsControl(pageSize, cookie, Control.CRITICAL) });
     } while (cookie != null);
     // Close the LDAP association
     ctx.close();
     ...
 
 此类实现在 RFC 2696 中定义的分页结果的 LDAPv3 控件。 控件值具有以下 ASN.1 定义:
     realSearchControlValue ::= SEQUENCE {
         size      INTEGER (0..maxInt),
                           -- requested page size from client
                           -- result set size estimate from server
         cookie    OCTET STRING
     }
 
PagedResultsResponseControl, 
序列化表格| 字段摘要 | |
|---|---|
| static String | OID分页结果控件的分配对象标识符为 1.2.840.113556.1.4.319。 | 
| 从类 javax.naming.ldap.BasicControl 继承的字段 | 
|---|
| criticality, id, value | 
| 从接口 javax.naming.ldap.Control 继承的字段 | 
|---|
| CRITICAL, NONCRITICAL | 
| 构造方法摘要 | |
|---|---|
| PagedResultsControl(int pageSize,
                    boolean criticality)构造一个控件来设置要在每页结果中返回的项数。 | |
| PagedResultsControl(int pageSize,
                    byte[] cookie,
                    boolean criticality)构造一个控件来设置要在每页结果中返回的项数。 | |
| 方法摘要 | 
|---|
| 从类 javax.naming.ldap.BasicControl 继承的方法 | 
|---|
| getEncodedValue, getID, isCritical | 
| 从类 java.lang.Object 继承的方法 | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| 字段详细信息 | 
|---|
public static final String OID
| 构造方法详细信息 | 
|---|
public PagedResultsControl(int pageSize,
                           boolean criticality)
                    throws IOException
pageSize - 要在一个页面中返回的项数。criticality - 如果为 true,则服务器必须遵从控件,按照 pageSize 的指示返回搜索结果或拒绝执行搜索。如果为 false,则服务器不必遵从控件。
IOException - 如果在将提供的参数编码到控件中时遇到错误。
public PagedResultsControl(int pageSize,
                           byte[] cookie,
                           boolean criticality)
                    throws IOException
通过将 pageSize 设置为零并将 cookie 设置为从服务器收到的最后一个 cookie,可以放弃分页结果序列。
pageSize - 要在一个页面中返回的项数。cookie - 服务器生成的 cookie(可能为 null)。criticality - 如果为 true,则服务器必须遵从控件,按照 pageSize 的指示返回搜索结果或拒绝执行搜索。如果为 false,则服务器不必遵从控件。
IOException - 如果在将提供的参数编码到控件中时遇到错误。| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。