KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > naming > ldap > SortKey


1 /*
2  * @(#)SortKey.java 1.4 04/04/20
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.naming.ldap;
9
10 /**
11  * A sort key and its associated sort parameters.
12  * This class implements a sort key which is used by the LDAPv3
13  * Control for server-side sorting of search results as defined in
14  * <a HREF="http://www.ietf.org/rfc/rfc2891.txt">RFC 2891</a>.
15  *
16  * @since 1.5
17  * @see SortControl
18  * @author Vincent Ryan
19  */

20 public class SortKey {
21
22     /*
23      * The ID of the attribute to sort by.
24      */

25     private String JavaDoc attrID;
26
27     /*
28      * The sort order. Ascending order, by default.
29      */

30     private boolean reverseOrder = false;
31
32     /*
33      * The ID of the matching rule to use for ordering attribute values.
34      */

35     private String JavaDoc matchingRuleID = null;
36
37     /**
38      * Creates the default sort key for an attribute. Entries will be sorted
39      * according to the specified attribute in ascending order using the
40      * ordering matching rule defined for use with that attribute.
41      *
42      * @param attrID The non-null ID of the attribute to be used as a sort
43      * key.
44      */

45     public SortKey(String JavaDoc attrID) {
46     this.attrID = attrID;
47     }
48
49     /**
50      * Creates a sort key for an attribute. Entries will be sorted according to
51      * the specified attribute in the specified sort order and using the
52      * specified matching rule, if supplied.
53      *
54      * @param attrID The non-null ID of the attribute to be used as
55      * a sort key.
56      * @param ascendingOrder If true then entries are arranged in ascending
57      * order. Otherwise there are arranged in
58      * descending order.
59      * @param matchingRuleID The possibly null ID of the matching rule to
60      * use to order the attribute values. If not
61      * specified then the ordering matching rule
62      * defined for the sort key attribute is used.
63      */

64     public SortKey(String JavaDoc attrID, boolean ascendingOrder,
65             String JavaDoc matchingRuleID) {
66
67     this.attrID = attrID;
68     reverseOrder = (! ascendingOrder);
69     this.matchingRuleID = matchingRuleID;
70     }
71
72     /**
73      * Retrieves the attribute ID of the sort key.
74      *
75      * @return The non-null Attribute ID of the sort key.
76      */

77     public String JavaDoc getAttributeID() {
78     return attrID;
79     }
80
81     /**
82      * Determines the sort order.
83      *
84      * @return true if the sort order is ascending, false if descending.
85      */

86     public boolean isAscending() {
87     return (! reverseOrder);
88     }
89
90     /**
91      * Retrieves the matching rule ID used to order the attribute values.
92      *
93      * @return The possibly null matching rule ID. If null then the
94      * ordering matching rule defined for the sort key attribute
95      * is used.
96      */

97     public String JavaDoc getMatchingRuleID() {
98     return matchingRuleID;
99     }
100 }
101
Popular Tags