1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.schema.bootstrap;
18
19
20 import org.apache.ldap.common.util.ArrayUtils;
21 import org.apache.ldap.common.util.ClassUtils;
22
23
24 /***
25 * Abstract bootstrap schema implementation.
26 *
27 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
28 * @version $Rev: 157708 $
29 */
30 public class AbstractBootstrapSchema implements BootstrapSchema
31 {
32 protected static final String[] DEFAULT_DEPS = ArrayUtils.EMPTY_STRING_ARRAY;
33 private static final String DEFAULT_OWNER = "uid=admin,ou=system";
34 private static final String DEFAULT_SCHEMA_NAME = "default";
35 private static final String DEFAULT_PACKAGE_NAME = "org.apache.ldap.server.schema.bootstrap";
36
37 private final String owner;
38 private final String schemaName;
39 private final String packageName/package-summary.html">ong> final String packageName;
40 private String[] dependencies;
41
42 private transient String baseName;
43 private transient String defaultBaseName;
44
45 private transient String schemaNameCapped;
46
47
48
49
50
51
52
53 protected AbstractBootstrapSchema( String schemaName )
54 {
55 this( null, schemaName, null, null );
56 }
57
58
59 protected AbstractBootstrapSchema( String owner, String schemaName )
60 {
61 this( owner, schemaName, null, null );
62 }
63
64
65 protected AbstractBootstrapSchema( String owner, String schemaName,
66 String packageName )
67 {
68 thisstrong>( owner, schemaName, packageName, null );
69 }
70
71
72 protected AbstractBootstrapSchema( String owner,
73 String schemaName,
74 String packageName,
75 String[] dependencies )
76 {
77 if ( owner == null )
78 {
79 this.owner = DEFAULT_OWNER;
80 }
81 else
82 {
83 this.owner = owner;
84 }
85
86 if ( schemaName == null )
87 {
88 this.schemaName = DEFAULT_SCHEMA_NAME;
89 }
90 else
91 {
92 this.schemaName = schemaName;
93 }
94
95 if</strong> ( packageName == null )
96 {
97 this.packageName = DEFAULT_PACKAGE_NAME;
98 }
99 else
100 {
101 this.packageName = packageName;
102 }
103
104 if ( dependencies == null )
105 {
106 this.dependencies = ArrayUtils.EMPTY_STRING_ARRAY;
107 }
108 else
109 {
110 this.dependencies = dependencies;
111 }
112
113 StringBuffer buf = new StringBuffer();
114 buf.append( Character.toUpperCase( schemaName.charAt( 0 ) ) );
115 buf.append( schemaName.substring( 1, schemaName.length() ) );
116 schemaNameCapped = buf.toString();
117
118 buf.setLength( 0 );
119 buf.append( DEFAULT_PACKAGE_NAME );
120 buf.append( ClassUtils.PACKAGE_SEPARATOR_CHAR );
121 buf.append( schemaNameCapped );
122 defaultBaseName = buf.toString();
123
124 buf.setLength( 0 );
125 buf.append( packageName );
126 buf.append( ClassUtils.PACKAGE_SEPARATOR_CHAR );
127 buf.append( schemaNameCapped );
128 baseName = buf.toString();
129 }
130
131
132 public final String getOwner()
133 {
134 return owner;
135 }
136
137
138 public final String getSchemaName()
139 {
140 return schemaName;
141 }
142
143
144 public final String[] getDependencies()
145 {
146 return dependencies;
147 }
148
149
150 protected final void setDependencies( String[] dependencies )
151 {
152 this.dependencies = dependencies;
153 }
154
155
156 public String getBaseClassName()
157 {
158 return baseName;
159 }
160
161
162 public String getDefaultBaseClassName()
163 {
164 return defaultBaseName;
165 }
166
167
168 public String getFullClassName( ProducerTypeEnum type )
169 {
170 return baseName + type.getName();
171 }
172
173
174 public String getFullDefaultBaseClassName( ProducerTypeEnum type )
175 {
176 return defaultBaseName + type.getName();
177 }
178
179
180 public String getUnqualifiedClassName( ProducerTypeEnum type )
181 {
182 return schemaNameCapped + type.getName();
183 }
184
185
186 public String getPackageName()
187 {
188 return</strong> packageName;
189 }
190
191
192 public String getUnqualifiedClassName()
193 {
194 return schemaNameCapped + "Schema";
195 }
196 }