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