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      * Add an extension with its values
223      * @param key The extension key
224      * @param values The associated values
225      */
226     void addExtension( String key, String... values );
227 
228 
229     /**
230      * Add an extension with its values
231      * @param key The extension key
232      * @param values The associated values
233      */
234     void addExtension( String key, List<String> values );
235 
236 
237     /**
238      * Add an extensions with their values. (Actually do a copy)
239      * 
240      * @param extensions The extensions map
241      */
242     void setExtensions( Map<String, List<String>> extensions );
243 
244 
245     /**
246      * The SchemaObject type :
247      * <li> AttributeType
248      * <li> DitCOntentRule
249      * <li> DitStructureRule
250      * <li> LdapComparator (specific to ADS)
251      * <li> LdapSyntaxe
252      * <li> MatchingRule
253      * <li> MatchingRuleUse
254      * <li> NameForm
255      * <li> Normalizer (specific to ADS)
256      * <li> ObjectClass
257      * <li> SyntaxChecker (specific to ADS)
258      * 
259      * @return the SchemaObject type
260      */
261     SchemaObjectType getObjectType();
262 
263 
264     /**
265      * Gets the name of the schema this SchemaObject is associated with.
266      *
267      * @return the name of the schema associated with this schemaObject
268      */
269     String getSchemaName();
270 
271 
272     /**
273      * Sets the name of the schema this SchemaObject is associated with.
274      * 
275      * @param schemaName the new schema name
276      */
277     void setSchemaName( String schemaName );
278 
279 
280     /**
281      * {@inheritDoc}
282      */
283     int hashCode();
284 
285 
286     /**
287      * {@inheritDoc}
288      */
289     boolean equals( Object o1 );
290 
291 
292     /**
293      * Copy the current SchemaObject on place
294      *
295      * @return The copied SchemaObject
296      */
297     SchemaObject copy();
298 
299 
300     /**
301      * Copies the given schema object into this schema object.
302      *
303      * @param original the original SchemaObject
304      * @return this
305      */
306     SchemaObject copy( SchemaObject original );
307 
308 
309     /**
310      * Clear the current SchemaObject : remove all the references to other objects,
311      * and all the Maps.
312      */
313     void clear();
314 
315 
316     /**
317      * Transform the SchemaObject to an immutable object
318      * TODO locked.
319      *
320      */
321     void lock();
322 }