|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjavax.naming.ldap.BasicControl
javax.naming.ldap.SortControl
public final class SortControl
請求 LDAP 伺服器在返回搜尋操作的結果前對這些結果進行排序。使用一個或多個排序鍵所組成的有序列表與關聯的排序參數一起指定排序標準。搜尋結果根據排序控制元件中提供的參數在 LDAP 伺服器排序,然後返回給請求方。如果伺服器上不支持排序(而排序控制元件被標記為關鍵),則不執行搜尋操作並返回錯誤。
以下程式碼範例展示了使用該類別的方式:
// Open an LDAP association
LdapContext ctx = new InitialLdapContext();
// Activate sorting
String sortKey = "cn";
ctx.setRequestControls(new Control[]{
new SortControl(sortKey, Control.CRITICAL) });
// Perform a search
NamingEnumeration results =
ctx.search("", "(objectclass=*)", new SearchControls());
// Iterate over 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 sort control response
Control[] controls = ctx.getResponseControls();
if (controls != null) {
for (int i = 0; i < controls.length; i++) {
if (controls[i] instanceof SortResponseControl) {
SortResponseControl src = (SortResponseControl)controls[i];
if (! src.isSorted()) {
throw src.getException();
}
} else {
// Handle other response controls (if any)
}
}
}
// Close the LDAP association
ctx.close();
...
此類別實作在 RFC 2891 中定義的用於伺服器端排序的 LDAPv3 請求控制元件。 控制元件值具有以下 ASN.1 定義:
SortKeyList ::= SEQUENCE OF SEQUENCE {
attributeType AttributeDescription,
orderingRule [0] MatchingRuleId OPTIONAL,
reverseOrder [1] BOOLEAN DEFAULT FALSE }
SortKey,
SortResponseControl,
序列化表格| 欄位摘要 | |
|---|---|
static String |
OID
伺服器端排序控制元件的分派物件標識符為 1.2.840.113556.1.4.473。 |
| 從類別 javax.naming.ldap.BasicControl 繼承的欄位 |
|---|
criticality, id, value |
| 從介面 javax.naming.ldap.Control 繼承的欄位 |
|---|
CRITICAL, NONCRITICAL |
| 建構子摘要 | |
|---|---|
SortControl(SortKey[] sortBy,
boolean criticality)
建構一個控制元件來對排序鍵列表進行排序。 |
|
SortControl(String[] sortBy,
boolean criticality)
建構一個控制元件來按升序對屬性列表進行排序。 |
|
SortControl(String sortBy,
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 SortControl(String sortBy,
boolean criticality)
throws IOException
sortBy - 用於排序的屬性 ID。criticality - 如果為 true,則伺服器屬性遵從控制元件,按照請求返回搜尋結果或拒絕執行搜尋。如果為 false,則伺服器不必遵從控制元件。
IOException - 如果在編碼控制元件中提供的參數時遇到錯誤。
public SortControl(String[] sortBy,
boolean criticality)
throws IOException
sortBy - 用於排序的非 null 屬性 ID 列表。列表按從高到低的排序鍵優先級順序排列。criticality - 如果為 true,則伺服器屬性遵從控制元件,按照請求返回搜尋結果或拒絕執行搜尋。如果為 false,則伺服器不必遵從控制元件。
IOException - 如果在編碼控制元件中提供的參數時遇到錯誤。
public SortControl(SortKey[] sortBy,
boolean criticality)
throws IOException
sortBy - 用於排序的非 null 鍵列表。列表按從高到低的排序鍵優先級順序排列。criticality - 如果為 true,則伺服器屬性遵從控制元件,按照請求返回搜尋結果或拒絕執行搜尋。如果為 false,則伺服器不必遵從控制元件。
IOException - 如果在編碼控制元件中提供的參數時遇到錯誤。
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。