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 * https://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.DitContentRule; 27 28 /** 29 * A parser for RFC 4512 DIT content rule descriptions. 30 * 31 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 32 */ 33 public class DitContentRuleDescriptionSchemaParser extends AbstractSchemaParser<DitContentRule> 34 { 35 36 /** 37 * Creates a schema parser instance. 38 */ 39 public DitContentRuleDescriptionSchemaParser() 40 { 41 super( DitContentRule.class, I18n.ERR_13833_CANNOT_PARSE_NULL_DCR, I18n.ERR_13834_DCR_PARSING_FAILURE, I18n.ERR_13835_DCR_DESC_PARSING_FAILURE ); 42 } 43 44 45 /** 46 * Parses a DIT content rule description according to RFC 4512: 47 * 48 * <pre> 49 * DITContentRuleDescription = LPAREN WSP 50 * numericoid ; object identifier 51 * [ SP "NAME" SP qdescrs ] ; short names (descriptors) 52 * [ SP "DESC" SP qdstring ] ; description 53 * [ SP "OBSOLETE" ] ; not active 54 * [ SP "AUX" SP oids ] ; auxiliary object classes 55 * [ SP "MUST" SP oids ] ; attribute types 56 * [ SP "MAY" SP oids ] ; attribute types 57 * [ SP "NOT" SP oids ] ; attribute types 58 * extensions WSP RPAREN ; extensions 59 * </pre> 60 * 61 * @param ditContentRuleDescription the DIT content rule description to be parsed 62 * @return the parsed DITContentRuleDescription bean 63 * @throws ParseException if there are any recognition errors (bad syntax) 64 */ 65 public DitContentRule parse( String ditContentRuleDescription ) throws ParseException 66 { 67 DitContentRule ditContentRule = fastParser.parseDitContentRule( ditContentRuleDescription ); 68 ditContentRule.setSpecification( ditContentRuleDescription ); 69 70 // Update the schemaName 71 updateSchemaName( ditContentRule ); 72 73 return ditContentRule; 74 } 75 }