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 */
020package org.apache.directory.api.ldap.model.schema.parsers;
021
022
023import java.text.ParseException;
024
025import org.apache.directory.api.i18n.I18n;
026import org.apache.directory.api.ldap.model.schema.DitStructureRule;
027
028import antlr.RecognitionException;
029import antlr.TokenStreamException;
030
031
032/**
033 * A parser for RFC 4512 DIT structure rule descriptions.
034 * 
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 */
037public class DitStructureRuleDescriptionSchemaParser extends AbstractSchemaParser<DitStructureRule>
038{
039
040    /**
041     * Creates a schema parser instance.
042     */
043    public DitStructureRuleDescriptionSchemaParser()
044    {
045        super( DitStructureRule.class, I18n.ERR_04233, I18n.ERR_04234, I18n.ERR_04235 );
046    }
047
048
049    /**
050     * Parses a DIT structure rule description according to RFC 4512:
051     * 
052     * <pre>
053     * DITStructureRuleDescription = LPAREN WSP
054     *   ruleid                     ; rule identifier
055     *   [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
056     *   [ SP "DESC" SP qdstring ]  ; description
057     *   [ SP "OBSOLETE" ]          ; not active
058     *   SP "FORM" SP oid           ; NameForm
059     *   [ SP "SUP" ruleids ]       ; superior rules
060     *   extensions WSP RPAREN      ; extensions
061     *
062     * ruleids = ruleid / ( LPAREN WSP ruleidlist WSP RPAREN )
063     * ruleidlist = ruleid *( SP ruleid )
064     * ruleid = numbers
065     * </pre>
066     * 
067     * @param ditStructureRuleDescription the DIT structure rule description to be parsed
068     * @return the parsed DITStructureRuleDescription bean
069     * @throws ParseException if there are any recognition errors (bad syntax)
070     */
071    public DitStructureRule parseDITStructureRuleDescription( String ditStructureRuleDescription )
072        throws ParseException
073    {
074        return super.parse( ditStructureRuleDescription );
075
076    }
077
078
079    /**
080     * {@inheritDoc}
081     */
082    @Override
083    protected DitStructureRule doParse() throws RecognitionException, TokenStreamException
084    {
085        return parser.ditStructureRuleDescription();
086    }
087}