(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap / LdapMatchingRuleSchema.cs
blob2e5212768b450ae21f2ff3e95e5c78ae5d541874
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc. www.novell.com
4 *
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
21 * SOFTWARE.
22 *******************************************************************************/
24 // Novell.Directory.Ldap.LdapMatchingRuleSchema.cs
26 // Author:
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
32 using System;
33 using SchemaParser = Novell.Directory.Ldap.Utilclass.SchemaParser;
35 namespace Novell.Directory.Ldap
37 /// <summary> The schematic definition of a particular matching rule
38 /// in a particular Directory Server.
39 ///
40 /// The LdapMatchingRuleSchema class represents the definition of a mathcing
41 /// rule. It is used to query matching rule syntax, and to add or delete a
42 /// matching rule definition in a directory.
43 ///
44 /// Novell eDirectory does not currently allow matching rules to be added
45 /// or deleted from the schema.
46 ///
47 /// </summary>
48 /// <seealso cref="LdapAttributeSchema">
49 /// </seealso>
50 /// <seealso cref="LdapSchemaElement">
51 /// </seealso>
52 /// <seealso cref="LdapSchema">
53 /// </seealso>
54 public class LdapMatchingRuleSchema:LdapSchemaElement
56 /// <summary> Returns the OIDs of the attributes to which this rule applies.
57 ///
58 /// </summary>
59 /// <returns> The OIDs of the attributes to which this matching rule applies.
60 /// </returns>
61 virtual public System.String[] Attributes
63 get
65 return attributes;
69 /// <summary> Returns the OID of the syntax that this matching rule is valid for.
70 ///
71 /// </summary>
72 /// <returns> The OID of the syntax that this matching rule is valid for.
73 /// </returns>
74 virtual public System.String SyntaxString
76 get
78 return syntaxString;
82 private System.String syntaxString;
83 private System.String[] attributes;
84 /// <summary> Constructs a matching rule definition for adding to or deleting from
85 /// a directory.
86 ///
87 /// </summary>
88 /// <param name="names"> The names of the attribute.
89 ///
90 /// </param>
91 /// <param name="oid"> Object Identifier of the attribute - in
92 /// dotted-decimal format.
93 ///
94 /// </param>
95 /// <param name="description"> Optional description of the attribute.
96 ///
97 /// </param>
98 /// <param name="attributes"> The OIDs of attributes to which the rule applies.
99 /// This parameter may be null. All attributes added to
100 /// this array must use the same syntax.
101 ///
102 /// </param>
103 /// <param name="obsolete"> true if this matching rule is obsolete.
104 ///
105 ///
106 /// </param>
107 /// <param name="syntaxString"> The unique object identifer of the syntax of the
108 /// attribute, in dotted numerical format.
109 ///
110 /// </param>
111 public LdapMatchingRuleSchema(System.String[] names, System.String oid, System.String description, System.String[] attributes, bool obsolete, System.String syntaxString):base(LdapSchema.schemaTypeNames[LdapSchema.MATCHING])
113 base.names = new System.String[names.Length];
114 names.CopyTo(base.names, 0);
115 base.oid = oid;
116 base.description = description;
117 base.obsolete = obsolete;
118 this.attributes = new System.String[attributes.Length];
119 attributes.CopyTo(this.attributes, 0);
120 this.syntaxString = syntaxString;
121 base.Value = formatString();
122 return ;
126 /// <summary> Constructs a matching rule definition from the raw string values
127 /// returned from a schema query for "matchingRule" and for
128 /// "matchingRuleUse" for the same rule.
129 ///
130 /// </summary>
131 /// <param name="rawMatchingRule"> The raw string value returned on a directory
132 /// query for "matchingRule".
133 ///
134 /// </param>
135 /// <param name="rawMatchingRuleUse"> The raw string value returned on a directory
136 /// query for "matchingRuleUse".
137 /// </param>
138 public LdapMatchingRuleSchema(System.String rawMatchingRule, System.String rawMatchingRuleUse):base(LdapSchema.schemaTypeNames[LdapSchema.MATCHING])
142 SchemaParser matchParser = new SchemaParser(rawMatchingRule);
143 base.names = new System.String[matchParser.Names.Length];
144 matchParser.Names.CopyTo(base.names, 0);
145 base.oid = matchParser.ID;
146 base.description = matchParser.Description;
147 base.obsolete = matchParser.Obsolete;
148 this.syntaxString = matchParser.Syntax;
149 if ((System.Object) rawMatchingRuleUse != null)
151 SchemaParser matchUseParser = new SchemaParser(rawMatchingRuleUse);
152 this.attributes = matchUseParser.Applies;
154 base.Value = formatString();
156 catch (System.IO.IOException e)
159 return ;
162 /// <summary> Returns a string in a format suitable for directly adding to a
163 /// directory, as a value of the particular schema element attribute.
164 ///
165 /// </summary>
166 /// <returns> A string representation of the attribute's definition.
167 /// </returns>
168 protected internal override System.String formatString()
171 System.Text.StringBuilder valueBuffer = new System.Text.StringBuilder("( ");
172 System.String token;
173 System.String[] strArray;
175 if ((System.Object) (token = ID) != null)
177 valueBuffer.Append(token);
179 strArray = Names;
180 if (strArray != null)
182 valueBuffer.Append(" NAME ");
183 if (strArray.Length == 1)
185 valueBuffer.Append("'" + strArray[0] + "'");
187 else
189 valueBuffer.Append("( ");
191 for (int i = 0; i < strArray.Length; i++)
193 valueBuffer.Append(" '" + strArray[i] + "'");
195 valueBuffer.Append(" )");
198 if ((System.Object) (token = Description) != null)
200 valueBuffer.Append(" DESC ");
201 valueBuffer.Append("'" + token + "'");
203 if (Obsolete)
205 valueBuffer.Append(" OBSOLETE");
207 if ((System.Object) (token = SyntaxString) != null)
209 valueBuffer.Append(" SYNTAX ");
210 valueBuffer.Append(token);
212 valueBuffer.Append(" )");
213 return valueBuffer.ToString();