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.exception.LdapNamingException;
27 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
28 import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
29 import org.apache.directory.shared.ldap.schema.AttributeType;
30 import org.apache.directory.shared.ldap.schema.MatchingRule;
31 import org.apache.directory.shared.ldap.schema.MutableSchemaObject;
32 import org.apache.directory.shared.ldap.schema.Syntax;
33 import org.apache.directory.shared.ldap.schema.UsageEnum;
34
35
36
37
38
39
40
41
42 class AttributeTypeImpl extends AbstractAttributeType implements MutableSchemaObject
43 {
44 private static final long serialVersionUID = 1L;
45
46 private final Registries registries;
47
48
49 private String syntaxOid;
50
51
52 private Syntax syntax;
53
54
55 private String equalityOid;
56
57
58 private MatchingRule equalityMR;
59
60
61 private String substrOid;
62
63
64 private MatchingRule substringMR;
65
66
67 private String orderingOid;
68
69
70 private MatchingRule orderingMR;
71
72 private String superiorOid;
73
74
75 public AttributeTypeImpl( String oid, Registries registries )
76 {
77 super( oid );
78 this.registries = registries;
79 }
80
81
82
83
84
85 public MatchingRule getEquality() throws NamingException
86 {
87 if ( equalityMR == null )
88 {
89 if ( equalityOid == null )
90 {
91 equalityMR = findEquality( getSuperior() );
92 }
93 else
94 {
95 equalityMR = registries.getMatchingRuleRegistry().lookup( equalityOid );
96 }
97 }
98
99 return equalityMR;
100 }
101
102
103
104
105
106
107
108
109
110 private MatchingRule findEquality( AttributeType at ) throws NamingException
111 {
112 if ( at == null )
113 {
114 return null;
115 }
116
117 MatchingRule mr = at.getEquality();
118
119 if ( mr == null )
120 {
121 return findEquality( at.getSuperior() );
122 }
123 else
124 {
125 return mr;
126 }
127 }
128
129
130
131
132
133 public MatchingRule getOrdering() throws NamingException
134 {
135 if ( orderingMR == null )
136 {
137 if ( orderingOid == null )
138 {
139 orderingMR = findOrdering( getSuperior() );
140 }
141 else
142 {
143 orderingMR = registries.getMatchingRuleRegistry().lookup( orderingOid );
144 }
145 }
146
147 return orderingMR;
148 }
149
150
151
152
153
154
155
156
157
158 private MatchingRule findOrdering( AttributeType at ) throws NamingException
159 {
160 if ( at == null )
161 {
162 return null;
163 }
164
165 MatchingRule mr = at.getOrdering();
166 if ( mr == null )
167 {
168 return findOrdering( at.getSuperior() );
169 }
170 else
171 {
172 return mr;
173 }
174 }
175
176
177
178
179
180 public MatchingRule getSubstr() throws NamingException
181 {
182 if ( substringMR == null )
183 {
184 if ( substrOid == null )
185 {
186 substringMR = findSubstr( getSuperior() );
187 }
188 else
189 {
190 substringMR = registries.getMatchingRuleRegistry().lookup( substrOid );
191 }
192 }
193
194 return substringMR;
195 }
196
197
198
199
200
201
202
203
204
205 private MatchingRule findSubstr( AttributeType at ) throws NamingException
206 {
207 if ( at == null )
208 {
209 return null;
210 }
211
212 MatchingRule mr = at.getSubstr();
213 if ( mr == null )
214 {
215 return findSubstr( at.getSuperior() );
216 }
217 else
218 {
219 return mr;
220 }
221 }
222
223
224
225
226
227 public AttributeType getSuperior() throws NamingException
228 {
229 if ( superiorOid == null )
230 {
231 return null;
232 }
233
234 return registries.getAttributeTypeRegistry().lookup( superiorOid );
235 }
236
237
238
239
240
241 public Syntax getSyntax() throws NamingException
242 {
243 if ( syntax == null )
244 {
245 if ( syntaxOid == null )
246 {
247 syntax = findSyntax( getSuperior() );
248 }
249 else
250 {
251 syntax = registries.getSyntaxRegistry().lookup( syntaxOid );
252 }
253 }
254
255 return syntax;
256 }
257
258
259
260
261
262
263
264
265
266 private Syntax findSyntax( AttributeType at ) throws NamingException
267 {
268 if ( at == null )
269 {
270 throw new LdapNamingException( "Cannot find syntax for attributeType " + getName()
271 + " after walking ancestors.", ResultCodeEnum.OTHER );
272 }
273
274 if ( at.getSyntax() != null )
275 {
276 return at.getSyntax();
277 }
278
279 return findSyntax( at.getSuperior() );
280 }
281
282
283 public void setSyntaxOid( String syntaxOid )
284 {
285 this.syntaxOid = syntaxOid;
286 }
287
288
289 public void setSchema( String schema )
290 {
291 super.setSchema( schema );
292 }
293
294
295 public void setSuperiorOid( String superiorOid )
296 {
297 this.superiorOid = superiorOid;
298 }
299
300
301 public void setEqualityOid( String equalityOid )
302 {
303 this.equalityOid = equalityOid;
304 }
305
306
307 public void setSubstrOid( String substrOid )
308 {
309 this.substrOid = substrOid;
310 }
311
312
313 public void setOrderingOid( String orderingOid )
314 {
315 this.orderingOid = orderingOid;
316 }
317
318
319 public void setDescription( String description )
320 {
321 super.setDescription( description );
322 }
323
324
325 public void setNames( String[] names )
326 {
327 super.setNames( names );
328 }
329
330
331 public void setObsolete( boolean obsolete )
332 {
333 super.setObsolete( obsolete );
334 }
335
336
337 public void setCollective( boolean collective )
338 {
339 super.setCollective( collective );
340 }
341
342
343 public void setCanUserModify( boolean canUserModify )
344 {
345 super.setCanUserModify( canUserModify );
346 }
347
348
349 public void setLength( int length )
350 {
351 super.setLength( length );
352 }
353
354
355 public void setSingleValue( boolean singleValue )
356 {
357 super.setSingleValue( singleValue );
358 }
359
360
361 public void setUsage( UsageEnum usage )
362 {
363 super.setUsage( usage );
364 }
365 }