View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    * 
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   * 
19   */
20  package org.apache.directory.api.ldap.model.schema;
21  
22  
23  import java.util.List;
24  import java.util.Map;
25  
26  
27  /**
28   * Most schema objects have some common attributes. This class
29   * contains the minimum set of properties exposed by a SchemaObject.<br>
30   * We have 11 types of SchemaObjects :
31   * <ul>
32   *   <li> AttributeType </li>
33   *   <li> DitCOntentRule </li>
34   *   <li> DitStructureRule </li>
35   *   <li> LdapComparator (specific to ADS) </li>
36   *   <li> LdapSyntaxe </li>
37   *   <li> MatchingRule </li>
38   *   <li> MatchingRuleUse </li>
39   *   <li> NameForm </li>
40   *   <li> Normalizer (specific to ADS) </li>
41   *   <li> ObjectClass </li>
42   *   <li> SyntaxChecker (specific to ADS) </li>
43   * </ul>
44   * <br>
45   * <br>
46   * This class provides accessors and setters for the following attributes,
47   * which are common to all those SchemaObjects :
48   * <ul>
49   *   <li>oid : The numeric OID </li>
50   *   <li>description : The SchemaObject description </li>
51   *   <li>obsolete : Tells if the schema object is obsolete </li>
52   *   <li>extensions : The extensions, a key/Values map </li>
53   *   <li>schemaObjectType : The SchemaObject type (see upper) </li>
54   *   <li>schema : The schema the SchemaObject is associated with (it's an extension).
55   *   Can be null </li>
56   *   <li>isEnabled : The SchemaObject status (it's related to the schema status) </li>
57   *   <li>isReadOnly : Tells if the SchemaObject can be modified or not </li>
58   * </ul>
59   * <br><br>
60   * Some of those attributes are not used by some Schema elements, even if they should
61   * have been used. Here is the list :
62   * <ul>
63   *   <li><b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker</li>
64   *   <li><b>numericOid</b> : DitStructureRule</li>
65   *   <li><b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker</li>
66   * </ul>
67   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
68   */
69  public interface SchemaObject
70  {
71      /**
72       * Gets usually what is the numeric object identifier assigned to this
73       * SchemaObject. All schema objects except for MatchingRuleUses have an OID
74       * assigned specifically to then. A MatchingRuleUse's OID really is the OID
75       * of it's MatchingRule and not specific to the MatchingRuleUse. This
76       * effects how MatchingRuleUse objects are maintained by the system.
77       * 
78       * @return an OID for this SchemaObject or its MatchingRule if this
79       *         SchemaObject is a MatchingRuleUse object
80       */
81      String getOid();
82  
83  
84      /**
85       * A special method used when renaming an SchemaObject: we may have to
86       * change it's OID
87       * @param oid The new OID
88       */
89      void setOid( String oid );
90  
91  
92      /**
93       * Gets short names for this SchemaObject if any exists for it, otherwise,
94       * returns an empty list.
95       * 
96       * @return the names for this SchemaObject
97       */
98      List<String> getNames();
99  
100 
101     /**
102      * Gets the first name in the set of short names for this SchemaObject if
103      * any exists for it.
104      * 
105      * @return the first of the names for this SchemaObject or the oid
106      * if one does not exist
107      */
108     String getName();
109 
110 
111     /**
112      * Add a new name to the list of names for this SchemaObject. The name
113      * is lower cased and trimmed.
114      * 
115      * @param names The names to add
116      */
117     void addName( String... names );
118 
119 
120     /**
121      * Sets the list of names for this SchemaObject. The names are
122      * lower cased and trimmed.
123      * 
124      * @param names The list of names. Can be empty
125      */
126     void setNames( List<String> names );
127 
128 
129     /**
130      * Gets a short description about this SchemaObject.
131      * 
132      * @return a short description about this SchemaObject
133      */
134     String getDescription();
135 
136 
137     /**
138      * Sets the SchemaObject's description
139      * 
140      * @param description The SchemaObject's description
141      */
142     void setDescription( String description );
143 
144 
145     /**
146      * Gets the SchemaObject specification.
147      * 
148      * @return the SchemaObject specification
149      */
150     String getSpecification();
151 
152 
153     /**
154      * Sets the SchemaObject's specification
155      * 
156      * @param specification The SchemaObject's specification
157      */
158     void setSpecification( String specification );
159 
160 
161     /**
162      * Tells if this SchemaObject is enabled.
163      * 
164      * @return true if the SchemaObject is enabled, or if it depends on
165      * an enabled schema
166      */
167     boolean isEnabled();
168 
169 
170     /**
171      * Tells if this SchemaObject is disabled.
172      * 
173      * @return true if the SchemaObject is disabled
174      */
175     boolean isDisabled();
176 
177 
178     /**
179      * Sets the SchemaObject state, either enabled or disabled.
180      * 
181      * @param enabled The current SchemaObject state
182      */
183     void setEnabled( boolean enabled );
184 
185 
186     /**
187      * Tells if this SchemaObject is ReadOnly.
188      * 
189      * @return true if the SchemaObject is not modifiable
190      */
191     boolean isReadOnly();
192 
193 
194     /**
195      * Sets the SchemaObject readOnly flag
196      * 
197      * @param isReadOnly The current SchemaObject ReadOnly status
198      */
199     void setReadOnly( boolean isReadOnly );
200 
201 
202     /**
203      * Gets whether or not this SchemaObject has been inactivated. All
204      * SchemaObjects except Syntaxes allow for this parameter within their
205      * definition. For Syntaxes this property should always return false in
206      * which case it is never included in the description.
207      * 
208      * @return true if inactive, false if active
209      */
210     boolean isObsolete();
211 
212 
213     /**
214      * Sets the Obsolete flag.
215      * 
216      * @param obsolete The Obsolete flag state
217      */
218     void setObsolete( boolean obsolete );
219 
220 
221     /**
222      * @return The SchemaObject extensions, as a Map of [extension, values]
223      */
224     Map<String, List<String>> getExtensions();
225 
226 
227     /**
228      * Check if a given extension is part of the SchemaObject. Extensions are case insensitive.
229      * 
230      * @param extension The extension we are looking for.
231      * @return <code>true</code> if the extension is present.
232      */
233     boolean hasExtension( String extension );
234 
235 
236     /**
237      * Get back the values associated with a given extension.
238      * 
239      * @param extension The extension we are looking for.
240      * @return The list of values associated with the extension
241      */
242     List<String> getExtension( String extension );
243 
244 
245     /**
246      * Add an extension with its values
247      * @param key The extension key
248      * @param values The associated values
249      */
250     void addExtension( String key, String... values );
251 
252 
253     /**
254      * Add an extension with its values
255      * @param key The extension key
256      * @param values The associated values
257      */
258     void addExtension( String key, List<String> values );
259 
260 
261     /**
262      * Add an extensions with their values. (Actually do a copy)
263      * 
264      * @param extensions The extensions map
265      */
266     void setExtensions( Map<String, List<String>> extensions );
267 
268 
269     /**
270      * The SchemaObject type :
271      * <ul>
272      *   <li> AttributeType</li>
273      *   <li> DitCOntentRule</li>
274      *   <li> DitStructureRule</li>
275      *   <li> LdapComparator (specific to ADS)</li>
276      *   <li> LdapSyntaxe</li>
277      *   <li> MatchingRule</li>
278      *   <li> MatchingRuleUse</li>
279      *   <li> NameForm</li>
280      *   <li> Normalizer (specific to ADS)</li>
281      *   <li> ObjectClass</li>
282      *   <li> SyntaxChecker (specific to ADS)</li>
283      * </ul>
284      * 
285      * @return the SchemaObject type
286      */
287     SchemaObjectType getObjectType();
288 
289 
290     /**
291      * Gets the name of the schema this SchemaObject is associated with.
292      *
293      * @return the name of the schema associated with this schemaObject
294      */
295     String getSchemaName();
296 
297 
298     /**
299      * Sets the name of the schema this SchemaObject is associated with.
300      * 
301      * @param schemaName the new schema name
302      */
303     void setSchemaName( String schemaName );
304 
305 
306     /**
307      * {@inheritDoc}
308      */
309     @Override
310     int hashCode();
311 
312 
313     /**
314      * {@inheritDoc}
315      */
316     @Override
317     boolean equals( Object o1 );
318 
319 
320     /**
321      * Copy the current SchemaObject on place
322      *
323      * @return The copied SchemaObject
324      */
325     SchemaObject copy();
326 
327 
328     /**
329      * Copies the given schema object into this schema object.
330      *
331      * @param original the original SchemaObject
332      * @return this
333      */
334     SchemaObject copy( SchemaObject original );
335 
336 
337     /**
338      * Clear the current SchemaObject : remove all the references to other objects,
339      * and all the Maps.
340      */
341     void clear();
342 
343 
344     /**
345      * Transform the SchemaObject to an immutable object
346      *
347      */
348     void lock();
349 }