1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Controls.LdapSortKey.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 namespace Novell
.Directory
.Ldap
.Controls
36 /// <summary> Encapsulates parameters for sorting search results.
38 public class LdapSortKey
40 /// <summary> Returns the attribute to used for sorting.
43 /// <returns> The name of the attribute used for sorting.
45 virtual public System
.String Key
53 /// <summary> Returns the sorting order, ascending or descending.
56 /// <returns> True if the sorting is done is descending order; false, if the
57 /// sorting is done is ascending order.
59 virtual public bool Reverse
67 /// <summary> Returns the OID to be used as a matching rule.
70 /// <returns> The OID to be used as matching rule, or null if none is to be
73 virtual public System
.String MatchRule
82 private System
.String key
;
84 private System
.String matchRule
;
88 /// <summary> Constructs a new LdapSortKey object using an attribute as the sort key.
91 /// <param name="keyDescription">The single attribute to use for sorting. If the
92 /// name is preceded by a minus sign (-), the sorting
93 /// is done in reverse (descending) order.
94 /// An OID for a matching rule may be appended
99 /// <li> "cn" (sorts in ascending order by the cn attribute)</li>
100 /// <li> "-cn" (sorts in descending order by the cn attribute) </li>
101 /// <li> "cn:1.2.3.4.5" (sorts in ascending order by the cn attribute
102 /// using the matching rule 1.2.3.4.5) </li>
105 public LdapSortKey(System
.String keyDescription
)
109 System
.String myKey
= keyDescription
;
112 myKey
= myKey
.Substring(1);
115 int pos
= myKey
.IndexOf(":");
118 this.key
= myKey
.Substring(0, (pos
) - (0));
119 this.matchRule
= myKey
.Substring(pos
+ 1);
128 /// <summary> Constructs a new LdapSortKey object with the specified attribute name
132 /// <param name="key"> The single attribute to use for sorting.
135 /// <param name="reverse">If true, sorting is done in descending order. If false,
136 /// sorting is done in ascending order.
138 public LdapSortKey(System
.String key
, bool reverse
):this(key
, reverse
, null)
143 /// <summary> Constructs a new LdapSortKey object with the specified attribute name,
144 /// sort order, and a matching rule.
147 /// <param name="key"> The attribute name (for example, "cn") to use for sorting.
150 /// <param name="reverse"> If true, sorting is done in descending order. If false,
151 /// sorting is done in ascending order.
154 /// <param name="matchRule"> The object ID (OID) of a matching rule used for
155 /// collation. If the object will be used to request
156 /// server-side sorting of search results, it should
157 /// be the OID of a matching rule known to be
158 /// supported by that server.
160 public LdapSortKey(System
.String key
, bool reverse
, System
.String matchRule
)
163 this.reverse
= reverse
;
164 this.matchRule
= matchRule
;