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;
026
027import antlr.RecognitionException;
028import antlr.TokenStreamException;
029
030
031/**
032 * A parser for ApacheDS normalizer descriptions.
033 * 
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 */
036public class NormalizerDescriptionSchemaParser extends AbstractSchemaParser<NormalizerDescription>
037{
038
039    /**
040     * Creates a schema parser instance.
041     */
042    public NormalizerDescriptionSchemaParser()
043    {
044        super( NormalizerDescription.class, I18n.ERR_04251, I18n.ERR_04252, I18n.ERR_04253 );
045    }
046
047
048    /**
049     * Parses a normalizer description:
050     * 
051     * <pre>
052     * NormalizerDescription = LPAREN WSP
053     *     numericoid                           ; object identifier
054     *     [ SP "DESC" SP qdstring ]            ; description
055     *     SP "FQCN" SP fqcn                    ; fully qualified class name
056     *     [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
057     *     extensions WSP RPAREN                ; extensions
058     * 
059     * base64          = *(4base64-char)
060     * base64-char     = ALPHA / DIGIT / "+" / "/"
061     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
062     * fqcnComponent = ???
063     * 
064     * extensions = *( SP xstring SP qdstrings )
065     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
066     * </pre>
067     * 
068     * @param normalizerDescription the normalizer description to be parsed
069     * @return the parsed NormalizerDescription bean
070     * @throws ParseException if there are any recognition errors (bad syntax)
071     */
072    public NormalizerDescription parseNormalizerDescription( String normalizerDescription ) throws ParseException
073    {
074        return super.parse( normalizerDescription );
075    }
076
077
078    @Override
079    protected NormalizerDescription doParse() throws RecognitionException, TokenStreamException
080    {
081        return parser.normalizerDescription();
082    }
083
084}