java.lang.Object
javax.naming.ldap.BasicControl
javax.naming.ldap.SortControl
- すべての実装されたインタフェース:
Serializable
,Control
public final class SortControl extends BasicControl
検索操作の結果をソートしてから返すようにLDAPサーバーに要求します。 ソート条件は、1つ以上のソート・キーとそのソート・パラメータを順に並べたリストで指定します。 検索結果は、ソート・コントロールで指定されたパラメータに従って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 }
- 導入されたバージョン:
- 1.5
- 関連項目:
-
フィールドのサマリー
クラスjavax.naming.ldap.BasicControlで宣言されたフィールド
criticality, id, value
インタフェースjavax.naming.ldap.Controlで宣言されているフィールド
CRITICAL, NONCRITICAL
-
コンストラクタのサマリー
コンストラクタ説明SortControl
(String[] sortBy, boolean criticality) 属性のリストに基づいて昇順にソートするためのコントロールを構築します。SortControl
(String sortBy, boolean criticality) 1つの属性に基づいて昇順にソートするためのコントロールを構築します。SortControl
(SortKey[] sortBy, boolean criticality) ソート・キーのリストに基づいてソートするためのコントロールを構築します。 -
メソッドのサマリー
クラスjavax.naming.ldap.BasicControlで宣言されたメソッド
getEncodedValue, getID, isCritical
-
フィールド詳細
-
OID
-
-
コンストラクタの詳細
-
SortControl
public SortControl(String sortBy, boolean criticality) throws IOException 1つの属性に基づいて昇順にソートするためのコントロールを構築します。 ソートの実行には、その属性に定義されている順序付けマッチング規則が使用されます。- パラメータ:
sortBy
- ソートの基準となる属性のID。criticality
- trueの場合、サーバーはこのコントロールに従い、要求されたとおりにソートされた検索結果を返すか、または検索の実行を拒否する必要がある。 falseの場合、サーバーはこのコントロールに従う必要はない。- 例外:
IOException
- 指定された引数のコントロールへのエンコード中にエラーが検出された場合。
-
SortControl
public SortControl(String[] sortBy, boolean criticality) throws IOException 属性のリストに基づいて昇順にソートするためのコントロールを構築します。 ソートの実行には、指定された各属性に定義されている順序付けマッチング規則が使用されます。- パラメータ:
sortBy
- ソートの基準となる属性のIDのリスト。nullは不可。 これらのソート・キーは、優先順位の高いものから順にリストに並べられる。criticality
- trueの場合、サーバーはこのコントロールに従い、要求されたとおりにソートされた検索結果を返すか、または検索の実行を拒否する必要がある。 falseの場合、サーバーはこのコントロールに従う必要はない。- 例外:
IOException
- 指定された引数のコントロールへのエンコード中にエラーが検出された場合。
-
SortControl
public SortControl(SortKey[] sortBy, boolean criticality) throws IOException ソート・キーのリストに基づいてソートするためのコントロールを構築します。 各ソート・キーは、ソート順序および使用する順序付けマッチング規則を指定します。- パラメータ:
sortBy
- ソートの基準となるキーのリスト。nullは不可。 これらのソート・キーは、優先順位の高いものから順にリストに並べられる。criticality
- trueの場合、サーバーはこのコントロールに従い、要求されたとおりにソートされた検索結果を返すか、または検索の実行を拒否する必要がある。 falseの場合、サーバーはこのコントロールに従う必要はない。- 例外:
IOException
- 指定された引数のコントロールへのエンコード中にエラーが検出された場合。
-