1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema;
21
22
23 import java.util.List;
24
25 import org.apache.directory.api.i18n.I18n;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 public class MutableObjectClass extends ObjectClass
72 {
73
74 public static final long serialVersionUID = 1L;
75
76
77
78
79
80
81 public MutableObjectClass( String oid )
82 {
83 super( oid );
84 }
85
86
87
88
89
90
91
92 public void addMayAttributeTypeOids( String... oids )
93 {
94 if ( locked )
95 {
96 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
97 }
98
99 if ( !isReadOnly )
100 {
101 for ( String oid : oids )
102 {
103 mayAttributeTypeOids.add( oid );
104 }
105 }
106 }
107
108
109
110
111
112
113
114 public void addMayAttributeTypes( AttributeType... attributeTypes )
115 {
116 if ( locked )
117 {
118 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
119 }
120
121 if ( !isReadOnly )
122 {
123 for ( AttributeType attributeType : attributeTypes )
124 {
125 if ( !mayAttributeTypeOids.contains( attributeType.getOid() ) )
126 {
127 mayAttributeTypes.add( attributeType );
128 mayAttributeTypeOids.add( attributeType.getOid() );
129 }
130 }
131 }
132 }
133
134
135
136
137
138 public void setMayAttributeTypeOids( List<String> mayAttributeTypeOids )
139 {
140 if ( locked )
141 {
142 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
143 }
144
145 if ( !isReadOnly )
146 {
147 this.mayAttributeTypeOids = mayAttributeTypeOids;
148 }
149 }
150
151
152
153
154
155
156
157 public void setMayAttributeTypes( List<AttributeType> mayAttributeTypes )
158 {
159 if ( locked )
160 {
161 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
162 }
163
164 if ( !isReadOnly )
165 {
166 this.mayAttributeTypes = mayAttributeTypes;
167
168
169 mayAttributeTypeOids.clear();
170
171 for ( AttributeType may : mayAttributeTypes )
172 {
173 mayAttributeTypeOids.add( may.getOid() );
174 }
175 }
176 }
177
178
179
180
181
182
183
184 public void updateMayAttributeTypes( List<AttributeType> mayAttributeTypes )
185 {
186 this.mayAttributeTypes.clear();
187 this.mayAttributeTypes.addAll( mayAttributeTypes );
188
189
190 mayAttributeTypeOids.clear();
191
192 for ( AttributeType may : mayAttributeTypes )
193 {
194 mayAttributeTypeOids.add( may.getOid() );
195 }
196 }
197
198
199
200
201
202
203
204 public void addMustAttributeTypeOids( String... oids )
205 {
206 if ( locked )
207 {
208 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
209 }
210
211 if ( !isReadOnly )
212 {
213 for ( String oid : oids )
214 {
215 mustAttributeTypeOids.add( oid );
216 }
217 }
218 }
219
220
221
222
223
224
225
226 public void addMustAttributeTypes( AttributeType... attributeTypes )
227 {
228 if ( locked )
229 {
230 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
231 }
232
233 if ( !isReadOnly )
234 {
235 for ( AttributeType attributeType : attributeTypes )
236 {
237 if ( !mustAttributeTypeOids.contains( attributeType.getOid() ) )
238 {
239 mustAttributeTypes.add( attributeType );
240 mustAttributeTypeOids.add( attributeType.getOid() );
241 }
242 }
243 }
244 }
245
246
247
248
249
250 public void setMustAttributeTypeOids( List<String> mustAttributeTypeOids )
251 {
252 if ( locked )
253 {
254 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
255 }
256
257 if ( !isReadOnly )
258 {
259 this.mustAttributeTypeOids = mustAttributeTypeOids;
260 }
261 }
262
263
264
265
266
267
268
269 public void setMustAttributeTypes( List<AttributeType> mustAttributeTypes )
270 {
271 if ( locked )
272 {
273 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
274 }
275
276 if ( !isReadOnly )
277 {
278 this.mustAttributeTypes = mustAttributeTypes;
279
280
281 mustAttributeTypeOids.clear();
282
283 for ( AttributeType may : mustAttributeTypes )
284 {
285 mustAttributeTypeOids.add( may.getOid() );
286 }
287 }
288 }
289
290
291
292
293
294
295
296 public void updateMustAttributeTypes( List<AttributeType> mustAttributeTypes )
297 {
298 this.mustAttributeTypes.clear();
299 this.mustAttributeTypes.addAll( mustAttributeTypes );
300
301
302 mustAttributeTypeOids.clear();
303
304 for ( AttributeType must : mustAttributeTypes )
305 {
306 mustAttributeTypeOids.add( must.getOid() );
307 }
308 }
309
310
311
312
313
314
315
316 public void addSuperiorOids( String... oids )
317 {
318 if ( locked )
319 {
320 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
321 }
322
323 if ( !isReadOnly )
324 {
325 for ( String oid : oids )
326 {
327 if ( !superiorOids.contains( oid ) )
328 {
329 superiorOids.add( oid );
330 }
331 }
332 }
333 }
334
335
336
337
338
339
340
341 public void addSuperior( MutableObjectClass... objectClasses )
342 {
343 if ( locked )
344 {
345 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
346 }
347
348 if ( !isReadOnly )
349 {
350 for ( MutableObjectClass objectClass : objectClasses )
351 {
352 if ( !superiorOids.contains( objectClass.getOid() ) )
353 {
354 superiorOids.add( objectClass.getOid() );
355 superiors.add( objectClass );
356 }
357 }
358 }
359 }
360
361
362
363
364
365
366
367 public void setSuperiors( List<ObjectClass> superiors )
368 {
369 if ( locked )
370 {
371 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
372 }
373
374 if ( !isReadOnly )
375 {
376 this.superiors = superiors;
377
378
379 superiorOids.clear();
380
381 for ( ObjectClass oc : superiors )
382 {
383 superiorOids.add( oc.getOid() );
384 }
385 }
386 }
387
388
389
390
391
392
393
394 public void updateSuperiors( List<ObjectClass> superiors )
395 {
396 this.superiors.clear();
397 this.superiors.addAll( superiors );
398
399
400 superiorOids.clear();
401
402 for ( ObjectClass oc : superiors )
403 {
404 superiorOids.add( oc.getOid() );
405 }
406 }
407
408
409
410
411
412
413
414 public void setSuperiorOids( List<String> superiorOids )
415 {
416 if ( locked )
417 {
418 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
419 }
420
421 if ( !isReadOnly )
422 {
423 this.superiorOids = superiorOids;
424 }
425 }
426
427
428
429
430
431
432
433 public void setType( ObjectClassTypeEnum objectClassType )
434 {
435 if ( locked )
436 {
437 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
438 }
439
440 if ( !isReadOnly )
441 {
442 this.objectClassType = objectClassType;
443 }
444 }
445
446
447
448
449
450 public void clear()
451 {
452
453 super.clear();
454
455
456 mayAttributeTypes.clear();
457 mayAttributeTypeOids.clear();
458 mustAttributeTypes.clear();
459 mustAttributeTypeOids.clear();
460 superiors.clear();
461 superiorOids.clear();
462 }
463 }