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