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.MutableSchemaObject;
29 import org.apache.directory.shared.ldap.schema.NameForm;
30 import org.apache.directory.shared.ldap.schema.ObjectClass;
31
32
33
34
35
36
37
38
39
40 public class NameFormImpl extends AbstractSchemaObject implements NameForm, MutableSchemaObject
41 {
42 private static final long serialVersionUID = 1L;
43 private static final String[] EMPTY_STR_ARRAY = new String[0];
44 private static final AttributeType[] EMPTY_ATTR_ARRAY = new AttributeType[0];
45
46
47 private final Registries registries;
48
49 private String objectClassOid;
50
51 private String[] mayUseOids = EMPTY_STR_ARRAY;
52 private AttributeType[] mayUse = EMPTY_ATTR_ARRAY;
53
54 private String[] mustUseOids = EMPTY_STR_ARRAY;
55 private AttributeType[] mustUse = EMPTY_ATTR_ARRAY;
56
57
58
59
60
61 public NameFormImpl( String oid, Registries registries )
62 {
63 super( oid );
64 this.registries = registries;
65 }
66
67
68 public void setMayUseOids( String[] mayUseOids )
69 {
70 if ( mayUseOids == null )
71 {
72 this.mayUse = EMPTY_ATTR_ARRAY;
73 this.mayUseOids = EMPTY_STR_ARRAY;
74 }
75 else
76 {
77 this.mayUse = new AttributeType[mayUseOids.length];
78 this.mayUseOids = mayUseOids;
79 }
80 }
81
82
83
84
85
86 public AttributeType[] getMayUse() throws NamingException
87 {
88 if ( mayUseOids == null || mayUseOids.length == 0 )
89 {
90 return EMPTY_ATTR_ARRAY;
91 }
92
93 for ( int ii = 0; ii < mayUseOids.length; ii++ )
94 {
95 mayUse[ii] = registries.getAttributeTypeRegistry().lookup( mayUseOids[ii] );
96 }
97
98 return mayUse;
99 }
100
101
102 public void setMustUseOids( String[] mustUseOids )
103 {
104 if ( mustUseOids == null )
105 {
106 this.mustUse = EMPTY_ATTR_ARRAY;
107 this.mustUseOids = EMPTY_STR_ARRAY;
108 }
109 else
110 {
111 this.mustUse = new AttributeType[mustUseOids.length];
112 this.mustUseOids = mustUseOids;
113 }
114 }
115
116
117
118
119
120 public AttributeType[] getMustUse() throws NamingException
121 {
122 if ( mustUseOids == null || mustUseOids.length == 0 )
123 {
124 return EMPTY_ATTR_ARRAY;
125 }
126
127 for ( int ii = 0; ii < mustUseOids.length; ii++ )
128 {
129 mustUse[ii] = registries.getAttributeTypeRegistry().lookup( mustUseOids[ii] );
130 }
131
132 return mustUse;
133 }
134
135
136 public void setObjectClassOid( String objectClassOid )
137 {
138 this.objectClassOid = objectClassOid;
139 }
140
141
142
143
144
145 public ObjectClass getObjectClass() throws NamingException
146 {
147 return registries.getObjectClassRegistry().lookup( objectClassOid );
148 }
149
150
151 public void setDescription( String description )
152 {
153 super.setDescription( description );
154 }
155
156
157 public void setObsolete( boolean obsolete )
158 {
159 super.setObsolete( obsolete );
160 }
161
162
163 public void setNames( String[] names )
164 {
165 super.setNames( names );
166 }
167
168
169 public void setSchema( String schema )
170 {
171 super.setSchema( schema );
172 }
173 }