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.AttributeType; 027 028import antlr.RecognitionException; 029import antlr.TokenStreamException; 030 031 032/** 033 * A parser for RFC 4512 attribute type descriptions. 034 * 035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 036 */ 037public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser<AttributeType> 038{ 039 040 /** 041 * Creates a schema parser instance. 042 */ 043 public AttributeTypeDescriptionSchemaParser() 044 { 045 super( AttributeType.class, I18n.ERR_04227, I18n.ERR_04228, I18n.ERR_04229 ); 046 047 } 048 049 050 /** 051 * Parses a attribute type description according to RFC 4512: 052 * 053 * <pre> 054 * AttributeTypeDescription = LPAREN WSP 055 * numericoid ; object identifier 056 * [ SP "NAME" SP qdescrs ] ; short names (descriptors) 057 * [ SP "DESC" SP qdstring ] ; description 058 * [ SP "OBSOLETE" ] ; not active 059 * [ SP "SUP" SP oid ] ; supertype 060 * [ SP "EQUALITY" SP oid ] ; equality matching rule 061 * [ SP "ORDERING" SP oid ] ; ordering matching rule 062 * [ SP "SUBSTR" SP oid ] ; substrings matching rule 063 * [ SP "SYNTAX" SP noidlen ] ; value syntax 064 * [ SP "SINGLE-VALUE" ] ; single-value 065 * [ SP "COLLECTIVE" ] ; collective 066 * [ SP "NO-USER-MODIFICATION" ] ; not user modifiable 067 * [ SP "USAGE" SP usage ] ; usage 068 * extensions WSP RPAREN ; extensions 069 * 070 * usage = "userApplications" / ; user 071 * "directoryOperation" / ; directory operational 072 * "distributedOperation" / ; DSA-shared operational 073 * "dSAOperation" ; DSA-specific operational 074 * 075 * extensions = *( SP xstring SP qdstrings ) 076 * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 077 * </pre> 078 * 079 * @param attributeTypeDescription the attribute type description to be parsed 080 * @return the parsed AttributeTypeDescription bean 081 * @throws ParseException if there are any recognition errors (bad syntax) 082 */ 083 public AttributeType parseAttributeTypeDescription( String attributeTypeDescription ) throws ParseException 084 { 085 return super.parse( attributeTypeDescription ); 086 } 087 088 089 /** 090 * {@inheritDoc} 091 */ 092 @Override 093 protected AttributeType doParse() throws RecognitionException, TokenStreamException 094 { 095 return parser.attributeTypeDescription(); 096 } 097 098}