001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.server.schema.bootstrap;
021    
022    
023    import javax.naming.NamingException;
024    
025    import org.apache.directory.server.constants.MetaSchemaConstants;
026    import org.apache.directory.server.schema.registries.Registries;
027    import org.apache.directory.shared.ldap.NotImplementedException;
028    import org.apache.directory.shared.ldap.schema.Syntax;
029    import org.apache.directory.shared.ldap.schema.SyntaxChecker;
030    import org.apache.directory.shared.ldap.schema.syntaxes.NumericOidSyntaxChecker;
031    import org.apache.directory.shared.ldap.schema.syntaxes.NumericStringSyntaxChecker;
032    import org.apache.directory.shared.ldap.schema.syntaxes.ObjectClassTypeSyntaxChecker;
033    import org.apache.directory.shared.ldap.schema.syntaxes.ObjectNameSyntaxChecker;
034    import org.apache.directory.shared.ldap.schema.syntaxes.OidSyntaxChecker;
035    
036    
037    /**
038     * A producer of Syntax objects for the apachemeta schema.
039     * Modified by hand from generated code
040     *
041     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
042     * @version $Rev$
043     */
044    public class ApachemetaSyntaxProducer extends AbstractBootstrapProducer
045    {
046        public ApachemetaSyntaxProducer()
047        {
048            super( ProducerTypeEnum.SYNTAX_PRODUCER );
049        }
050    
051    
052        // ------------------------------------------------------------------------
053        // BootstrapProducer Methods
054        // ------------------------------------------------------------------------
055    
056    
057        /**
058         * @see BootstrapProducer#produce(DefaultRegistries, ProducerCallback)
059         */
060        public void produce( Registries registries, ProducerCallback cb )
061            throws NamingException
062        {
063            Syntax syntax = null;
064            
065            syntax = new NameOrNumericIdSyntax();
066            cb.schemaObjectProduced( this, syntax.getOid(), syntax );
067    
068            syntax = new NumericOidSyntax();
069            cb.schemaObjectProduced( this, syntax.getOid(), syntax );
070    
071            syntax = new ObjectClassTypeSyntax();
072            cb.schemaObjectProduced( this, syntax.getOid(), syntax );
073    
074            syntax = new NumberSyntax();
075            cb.schemaObjectProduced( this, syntax.getOid(), syntax );
076    
077            syntax = new ObjectNameSyntax();
078            cb.schemaObjectProduced( this, syntax.getOid(), syntax );
079        }
080        
081        
082        public static class NumericOidSyntax implements Syntax
083        {
084            private static final long serialVersionUID = 1L;
085            private final static String OID = "1.3.6.1.4.1.18060.0.4.0.0.2";
086            private final static SyntaxChecker CHECKER = new OidSyntaxChecker();
087            private final static String[] NAMES = new String[] { "numericOid" };
088            
089            public final SyntaxChecker getSyntaxChecker() throws NamingException
090            {
091                return CHECKER;
092            }
093    
094            public final boolean isHumanReadable()
095            {
096                return true;
097            }
098    
099            public final String getDescription()
100            {
101                return "The syntax for numericoids.";
102            }
103    
104            public final String getName()
105            {
106                return NAMES[0];
107            }
108    
109            public final String[] getNamesRef()
110            {
111                return NAMES;
112            }
113    
114            public final String getOid()
115            {
116                return OID;
117            }
118    
119            public final boolean isObsolete()
120            {
121                return false;
122            }
123    
124            public String getSchema()
125            {
126                return MetaSchemaConstants.SCHEMA_NAME;
127            }
128    
129            public void setSchema( String schemaName )
130            {
131                throw new NotImplementedException();
132            }
133        }
134    
135    
136        public static class NameOrNumericIdSyntax implements Syntax
137        {
138            private static final long serialVersionUID = 1L;
139            private final static String OID = "1.3.6.1.4.1.18060.0.4.0.0.0";
140            private final static SyntaxChecker CHECKER = new NumericOidSyntaxChecker();
141            private final static String[] NAMES = new String[] { "nameOrOid" };
142            
143            public final SyntaxChecker getSyntaxChecker() throws NamingException
144            {
145                return CHECKER;
146            }
147    
148            public final boolean isHumanReadable()
149            {
150                return true;
151            }
152    
153            public final String getDescription()
154            {
155                return "The syntax for either numeric ids or names.";
156            }
157    
158            public final String getName()
159            {
160                return NAMES[0];
161            }
162    
163            public final String[] getNamesRef()
164            {
165                return NAMES;
166            }
167    
168            public final String getOid()
169            {
170                return OID;
171            }
172    
173            public final boolean isObsolete()
174            {
175                return false;
176            }
177    
178            public String getSchema()
179            {
180                return MetaSchemaConstants.SCHEMA_NAME;
181            }
182    
183            public void setSchema( String schemaName )
184            {
185                throw new NotImplementedException();
186            }
187        }
188    
189    
190        public static class ObjectClassTypeSyntax implements Syntax
191        {
192            private static final long serialVersionUID = 1L;
193            private final static String OID = "1.3.6.1.4.1.18060.0.4.0.0.1";
194            private final static SyntaxChecker CHECKER = new ObjectClassTypeSyntaxChecker();
195            private final static String[] NAMES = new String[] { "objectClassType" };
196            
197            public final SyntaxChecker getSyntaxChecker() throws NamingException
198            {
199                return CHECKER;
200            }
201    
202            public final boolean isHumanReadable()
203            {
204                return true;
205            }
206    
207            public final String getDescription()
208            {
209                return "The syntax for either numeric ids or names.";
210            }
211    
212            public final String getName()
213            {
214                return NAMES[0];
215            }
216    
217            public final String[] getNamesRef()
218            {
219                return NAMES;
220            }
221    
222            public final String getOid()
223            {
224                return OID;
225            }
226    
227            public final boolean isObsolete()
228            {
229                return false;
230            }
231    
232            public String getSchema()
233            {
234                return MetaSchemaConstants.SCHEMA_NAME;
235            }
236    
237            public void setSchema( String schemaName )
238            {
239                throw new NotImplementedException();
240            }
241        }
242    
243    
244        public static class NumberSyntax implements Syntax
245        {
246            private static final long serialVersionUID = 1L;
247            private final static String OID = "1.3.6.1.4.1.18060.0.4.0.0.4";
248            private final static SyntaxChecker CHECKER = new NumericStringSyntaxChecker();
249            private final static String[] NAMES = new String[] { "numeric" };
250            
251            public final SyntaxChecker getSyntaxChecker() throws NamingException
252            {
253                return CHECKER;
254            }
255    
256            public final boolean isHumanReadable()
257            {
258                return true;
259            }
260    
261            public final String getDescription()
262            {
263                return "The syntax for numeric strings.";
264            }
265    
266            public final String getName()
267            {
268                return NAMES[0];
269            }
270    
271            public final String[] getNamesRef()
272            {
273                return NAMES;
274            }
275    
276            public final String getOid()
277            {
278                return OID;
279            }
280    
281            public final boolean isObsolete()
282            {
283                return false;
284            }
285    
286            public String getSchema()
287            {
288                return MetaSchemaConstants.SCHEMA_NAME;
289            }
290    
291            public void setSchema( String schemaName )
292            {
293                throw new NotImplementedException();
294            }
295        }
296    
297        public static class ObjectNameSyntax implements Syntax
298        {
299            private static final long serialVersionUID = 1L;
300            private final static String OID = "1.3.6.1.4.1.18060.0.4.0.0.6";
301            private final static SyntaxChecker CHECKER = new ObjectNameSyntaxChecker();
302            private final static String[] NAMES = new String[] { "objectName" };
303            
304            public final SyntaxChecker getSyntaxChecker() throws NamingException
305            {
306                return CHECKER;
307            }
308    
309            public final boolean isHumanReadable()
310            {
311                return true;
312            }
313    
314            public final String getDescription()
315            {
316                return "The syntax for object names.";
317            }
318    
319            public final String getName()
320            {
321                return NAMES[0];
322            }
323    
324            public final String[] getNamesRef()
325            {
326                return NAMES;
327            }
328    
329            public final String getOid()
330            {
331                return OID;
332            }
333    
334            public final boolean isObsolete()
335            {
336                return false;
337            }
338    
339            public String getSchema()
340            {
341                return MetaSchemaConstants.SCHEMA_NAME;
342            }
343    
344            public void setSchema( String schemaName )
345            {
346                throw new NotImplementedException();
347            }
348        }
349    }