1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.schema;
21
22
23 import javax.naming.NamingException;
24
25 import org.apache.directory.server.schema.registries.Registries;
26 import org.apache.directory.shared.ldap.schema.AbstractSchemaObject;
27 import org.apache.directory.shared.ldap.schema.AttributeType;
28 import org.apache.directory.shared.ldap.schema.DITContentRule;
29 import org.apache.directory.shared.ldap.schema.MutableSchemaObject;
30 import org.apache.directory.shared.ldap.schema.ObjectClass;
31
32
33
34
35
36
37
38
39
40 public class DitContentRuleImpl extends AbstractSchemaObject implements MutableSchemaObject, DITContentRule
41 {
42 private static final long serialVersionUID = 1L;
43 private static final String[] EMPTY_STR_ARRAY = new String[0];
44 private static final ObjectClass[] EMPTY_OC_ARRAY = new ObjectClass[0];
45 private static final AttributeType[] EMPTY_ATTR_ARRAY = new AttributeType[0];
46
47 private final Registries registries;
48
49 private String[] auxObjectClassOids = EMPTY_STR_ARRAY;
50 private ObjectClass[] auxObjectClasses = EMPTY_OC_ARRAY;
51
52 private String[] mustNameOids = EMPTY_STR_ARRAY;
53 private AttributeType[] mustNames = EMPTY_ATTR_ARRAY;
54
55 private String[] mayNameOids = EMPTY_STR_ARRAY;
56 private AttributeType[] mayNames = EMPTY_ATTR_ARRAY;
57
58 private String[] notNameOids = EMPTY_STR_ARRAY;
59 private AttributeType[] notNames = EMPTY_ATTR_ARRAY;
60
61
62 protected DitContentRuleImpl( String oid, Registries registries )
63 {
64 super( oid );
65 this.registries = registries;
66 }
67
68
69 public void setAuxObjectClassOids( String[] auxObjectClassOids )
70 {
71 if ( auxObjectClassOids == null )
72 {
73 this.auxObjectClassOids = EMPTY_STR_ARRAY;
74 this.auxObjectClasses = EMPTY_OC_ARRAY;
75 }
76 else
77 {
78 this.auxObjectClassOids = auxObjectClassOids;
79 this.auxObjectClasses = new ObjectClass[auxObjectClassOids.length];
80 }
81 }
82
83
84
85
86
87 public ObjectClass[] getAuxObjectClasses() throws NamingException
88 {
89 if ( auxObjectClassOids == null || auxObjectClassOids.length == 0 )
90 {
91 return EMPTY_OC_ARRAY;
92 }
93
94 for ( int ii = 0; ii < auxObjectClassOids.length; ii++ )
95 {
96 auxObjectClasses[ii] = registries.getObjectClassRegistry().lookup( auxObjectClassOids[ii] );
97 }
98
99 return auxObjectClasses;
100 }
101
102
103 public void setMayNameOids( String[] mayNameOids )
104 {
105 if ( mayNameOids == null )
106 {
107 this.mayNameOids = EMPTY_STR_ARRAY;
108 this.mayNames = EMPTY_ATTR_ARRAY;
109 }
110 else
111 {
112 this.mayNameOids = mayNameOids;
113 this.mayNames = new AttributeType[mayNameOids.length];
114 }
115 }
116
117
118
119
120
121 public AttributeType[] getMayNames() throws NamingException
122 {
123 if ( mayNameOids == null || mayNameOids.length == 0 )
124 {
125 return EMPTY_ATTR_ARRAY;
126 }
127
128 for ( int ii = 0; ii < mayNameOids.length; ii++ )
129 {
130 mayNames[ii] = registries.getAttributeTypeRegistry().lookup( mayNameOids[ii] );
131 }
132
133 return mayNames;
134 }
135
136
137 public void setMustNameOids( String[] mustNameOids )
138 {
139 if ( mustNameOids == null )
140 {
141 this.mustNameOids = EMPTY_STR_ARRAY;
142 this.mustNames = EMPTY_ATTR_ARRAY;
143 }
144 else
145 {
146 this.mustNameOids = mustNameOids;
147 this.mustNames = new AttributeType[mustNameOids.length];
148 }
149 }
150
151
152
153
154
155 public AttributeType[] getMustNames() throws NamingException
156 {
157 if ( mustNameOids == null || mustNameOids.length == 0 )
158 {
159 return EMPTY_ATTR_ARRAY;
160 }
161
162 for ( int ii = 0; ii < mustNameOids.length; ii++ )
163 {
164 mustNames[ii] = registries.getAttributeTypeRegistry().lookup( mustNameOids[ii] );
165 }
166
167 return mustNames;
168 }
169
170
171 public void setNotNameOids( String[] notNameOids )
172 {
173 if ( notNameOids == null )
174 {
175 this.notNameOids = EMPTY_STR_ARRAY;
176 this.notNames = EMPTY_ATTR_ARRAY;
177 }
178 else
179 {
180 this.notNameOids = notNameOids;
181 this.notNames = new AttributeType[notNameOids.length];
182 }
183 }
184
185
186
187
188
189 public AttributeType[] getNotNames() throws NamingException
190 {
191 if ( notNameOids == null || notNameOids.length == 0 )
192 {
193 return EMPTY_ATTR_ARRAY;
194 }
195
196 for ( int ii = 0; ii < notNameOids.length; ii++ )
197 {
198 notNames[ii] = registries.getAttributeTypeRegistry().lookup( notNameOids[ii] );
199 }
200
201 return notNames;
202 }
203
204
205
206
207
208 public ObjectClass getObjectClass() throws NamingException
209 {
210 return registries.getObjectClassRegistry().lookup( getOid() );
211 }
212
213
214 public void setDescription( String description )
215 {
216 super.setDescription( description );
217 }
218
219
220 public void setObsolete( boolean obsolete )
221 {
222 super.setObsolete( obsolete );
223 }
224
225
226 public void setNames( String[] names )
227 {
228 super.setNames( names );
229 }
230
231
232 public void setSchema( String schema )
233 {
234 super.setSchema( schema );
235 }
236 }