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 * https://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.DitContentRule; 027 028/** 029 * A parser for RFC 4512 DIT content rule descriptions. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public class DitContentRuleDescriptionSchemaParser extends AbstractSchemaParser<DitContentRule> 034{ 035 036 /** 037 * Creates a schema parser instance. 038 */ 039 public DitContentRuleDescriptionSchemaParser() 040 { 041 super( DitContentRule.class, I18n.ERR_13833_CANNOT_PARSE_NULL_DCR, I18n.ERR_13834_DCR_PARSING_FAILURE, I18n.ERR_13835_DCR_DESC_PARSING_FAILURE ); 042 } 043 044 045 /** 046 * Parses a DIT content rule description according to RFC 4512: 047 * 048 * <pre> 049 * DITContentRuleDescription = LPAREN WSP 050 * numericoid ; object identifier 051 * [ SP "NAME" SP qdescrs ] ; short names (descriptors) 052 * [ SP "DESC" SP qdstring ] ; description 053 * [ SP "OBSOLETE" ] ; not active 054 * [ SP "AUX" SP oids ] ; auxiliary object classes 055 * [ SP "MUST" SP oids ] ; attribute types 056 * [ SP "MAY" SP oids ] ; attribute types 057 * [ SP "NOT" SP oids ] ; attribute types 058 * extensions WSP RPAREN ; extensions 059 * </pre> 060 * 061 * @param ditContentRuleDescription the DIT content rule description to be parsed 062 * @return the parsed DITContentRuleDescription bean 063 * @throws ParseException if there are any recognition errors (bad syntax) 064 */ 065 public DitContentRule parse( String ditContentRuleDescription ) throws ParseException 066 { 067 DitContentRule ditContentRule = fastParser.parseDitContentRule( ditContentRuleDescription ); 068 ditContentRule.setSpecification( ditContentRuleDescription ); 069 070 // Update the schemaName 071 updateSchemaName( ditContentRule ); 072 073 return ditContentRule; 074 } 075}