KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > schema > bootstrap > AbstractBootstrapSchema


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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: 169198 $
29  */

30 public class AbstractBootstrapSchema implements BootstrapSchema
31 {
32     protected static final String JavaDoc[] DEFAULT_DEPS = ArrayUtils.EMPTY_STRING_ARRAY;
33     private static final String JavaDoc DEFAULT_OWNER = "uid=admin,ou=system";
34     private static final String JavaDoc DEFAULT_SCHEMA_NAME = "default";
35     private static final String JavaDoc DEFAULT_PACKAGE_NAME = "org.apache.ldap.server.schema.bootstrap";
36
37     private final String JavaDoc owner;
38     private final String JavaDoc schemaName;
39     private final String JavaDoc packageName;
40     private String JavaDoc[] dependencies;
41
42     private transient String JavaDoc baseName;
43     private transient String JavaDoc defaultBaseName;
44
45     private transient String JavaDoc schemaNameCapped;
46
47
48     // ------------------------------------------------------------------------
49
// C O N S T R U C T O R S
50
// ------------------------------------------------------------------------
51

52
53     protected AbstractBootstrapSchema( String JavaDoc schemaName )
54     {
55         this( null, schemaName, null, null );
56     }
57
58
59     protected AbstractBootstrapSchema( String JavaDoc owner, String JavaDoc schemaName )
60     {
61         this( owner, schemaName, null, null );
62     }
63
64
65     protected AbstractBootstrapSchema( String JavaDoc owner, String JavaDoc schemaName,
66                                        String JavaDoc packageName )
67     {
68         this( owner, schemaName, packageName, null );
69     }
70
71
72     protected AbstractBootstrapSchema( String JavaDoc owner,
73                                        String JavaDoc schemaName,
74                                        String JavaDoc packageName,
75                                        String JavaDoc[] 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 ( 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 JavaDoc buf = new StringBuffer JavaDoc();
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 JavaDoc getOwner()
133     {
134         return owner;
135     }
136
137
138     public final String JavaDoc getSchemaName()
139     {
140         return schemaName;
141     }
142
143
144     public final String JavaDoc[] getDependencies()
145     {
146         return dependencies;
147     }
148
149
150     protected final void setDependencies( String JavaDoc[] dependencies )
151     {
152         this.dependencies = dependencies;
153     }
154
155
156     public String JavaDoc getBaseClassName()
157     {
158         return baseName;
159     }
160
161
162     public String JavaDoc getDefaultBaseClassName()
163     {
164         return defaultBaseName;
165     }
166
167
168     public String JavaDoc getFullClassName( ProducerTypeEnum type )
169     {
170         return baseName + type.getName();
171     }
172
173
174     public String JavaDoc getFullDefaultBaseClassName( ProducerTypeEnum type )
175     {
176         return defaultBaseName + type.getName();
177     }
178
179
180     public String JavaDoc getUnqualifiedClassName( ProducerTypeEnum type )
181     {
182         return schemaNameCapped + type.getName();
183     }
184
185
186     public String JavaDoc getPackageName()
187     {
188         return packageName;
189     }
190
191
192     public String JavaDoc getUnqualifiedClassName()
193     {
194         return schemaNameCapped + "Schema";
195     }
196 }
197
Popular Tags