View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.model.schema.parsers;
21  
22  
23  import java.text.ParseException;
24  
25  import org.apache.directory.api.i18n.I18n;
26  import org.apache.directory.api.ldap.model.schema.AttributeType;
27  
28  import antlr.RecognitionException;
29  import antlr.TokenStreamException;
30  
31  
32  /**
33   * A parser for RFC 4512 attribute type descriptions.
34   * 
35   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
36   */
37  public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser<AttributeType>
38  {
39  
40      /**
41       * Creates a schema parser instance.
42       */
43      public AttributeTypeDescriptionSchemaParser()
44      {
45          super( AttributeType.class, I18n.ERR_04227, I18n.ERR_04228, I18n.ERR_04229 );
46  
47      }
48  
49  
50      /**
51       * Parses a attribute type description according to RFC 4512:
52       * 
53       * <pre>
54       * AttributeTypeDescription = LPAREN WSP
55       *     numericoid                    ; object identifier
56       *     [ SP "NAME" SP qdescrs ]      ; short names (descriptors)
57       *     [ SP "DESC" SP qdstring ]     ; description
58       *     [ SP "OBSOLETE" ]             ; not active
59       *     [ SP "SUP" SP oid ]           ; supertype
60       *     [ SP "EQUALITY" SP oid ]      ; equality matching rule
61       *     [ SP "ORDERING" SP oid ]      ; ordering matching rule
62       *     [ SP "SUBSTR" SP oid ]        ; substrings matching rule
63       *     [ SP "SYNTAX" SP noidlen ]    ; value syntax
64       *     [ SP "SINGLE-VALUE" ]         ; single-value
65       *     [ SP "COLLECTIVE" ]           ; collective
66       *     [ SP "NO-USER-MODIFICATION" ] ; not user modifiable
67       *     [ SP "USAGE" SP usage ]       ; usage
68       *     extensions WSP RPAREN         ; extensions
69       * 
70       * usage = "userApplications"     /  ; user
71       *         "directoryOperation"   /  ; directory operational
72       *         "distributedOperation" /  ; DSA-shared operational
73       *         "dSAOperation"            ; DSA-specific operational     
74       * 
75       * extensions = *( SP xstring SP qdstrings )
76       * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
77       * </pre>
78       * 
79       * @param attributeTypeDescription the attribute type description to be parsed
80       * @return the parsed AttributeTypeDescription bean
81       * @throws ParseException if there are any recognition errors (bad syntax)
82       */
83      public AttributeType parseAttributeTypeDescription( String attributeTypeDescription ) throws ParseException
84      {
85          return super.parse( attributeTypeDescription );
86      }
87  
88  
89      /**
90       * {@inheritDoc}
91       */
92      @Override
93      protected AttributeType doParse() throws RecognitionException, TokenStreamException
94      {
95          return parser.attributeTypeDescription();
96      }
97  
98  }