You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2015/02/21 22:41:01 UTC
svn commit: r1661442 -
/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/
Author: seelmann
Date: Sat Feb 21 21:41:00 2015
New Revision: 1661442
URL: http://svn.apache.org/r1661442
Log:
* Refactored schema parsers, move duplicated code to abstract base class.
* Keep cause of parse exception
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AttributeTypeDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitContentRuleDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitStructureRuleDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleUseDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NameFormDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ObjectClassDescriptionSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,19 +24,27 @@ import java.io.StringReader;
import java.text.ParseException;
import java.util.List;
+import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.constants.MetaSchemaConstants;
import org.apache.directory.api.ldap.model.schema.SchemaObject;
import org.apache.directory.api.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+import antlr.TokenStreamRecognitionException;
/**
- *
- * TODO AbstractSchemaParser.
+ * Base class of all schema parsers.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class AbstractSchemaParser
+public abstract class AbstractSchemaParser<T extends SchemaObject>
{
+ /** The LoggerFactory used by this class */
+ protected static final Logger LOG = LoggerFactory.getLogger( AbstractSchemaParser.class );
/** the monitor to use for this parser */
protected ParserMonitor monitor = new ParserMonitorAdapter();
@@ -47,12 +55,32 @@ public abstract class AbstractSchemaPars
/** the antlr generated lexer being wrapped */
protected ReusableAntlrSchemaLexer lexer;
+ /** the schema object sub-type */
+ private Class<T> schemaObjectType;
+
+ /** error code used when schema descritpion is null */
+ private I18n errorCodeOnNull;
+
+ /** error code used on parse error when position is known */
+ private I18n errorCodeOnParseExceptionWithPosition;
+
+ /** error code used on parse error when position is unknown */
+ private I18n errorCodeOnParseException;
+
/**
* Instantiates a new abstract schema parser.
- */
- protected AbstractSchemaParser()
- {
+ * @param errorCodeOnNull error code used when schema element is null
+ * @param errorCodeOnParseExceptionWithPosition error code used on parse error when position is known
+ * @param errorCodeOnParseException error code used on parse error when position is unknown
+ */
+ protected AbstractSchemaParser( Class<T> schemaObjectType, I18n errorCodeOnNull, I18n errorCodeOnParseExceptionWithPosition,
+ I18n errorCodeOnParseException )
+ {
+ this.schemaObjectType = schemaObjectType;
+ this.errorCodeOnNull = errorCodeOnNull;
+ this.errorCodeOnParseExceptionWithPosition = errorCodeOnParseExceptionWithPosition;
+ this.errorCodeOnParseException = errorCodeOnParseException;
lexer = new ReusableAntlrSchemaLexer( new StringReader( "" ) );
parser = new ReusableAntlrSchemaParser( lexer );
}
@@ -116,7 +144,83 @@ public abstract class AbstractSchemaPars
* @return A SchemaObject instance
* @throws ParseException If the parsing failed
*/
- public abstract SchemaObject parse( String schemaDescription ) throws ParseException;
+ public synchronized T parse( String schemaDescription ) throws ParseException
+ {
+ LOG.debug( "Parsing a {} : {}", schemaObjectType.getClass().getSimpleName(), schemaDescription );
+
+ if ( schemaDescription == null )
+ {
+ LOG.error( I18n.err( errorCodeOnNull ) );
+ throw new ParseException( "Null", 0 );
+ }
+
+ reset( schemaDescription ); // reset and initialize the parser / lexer pair
+
+ try
+ {
+ T schemaObject = doParse();
+ schemaObject.setSpecification( schemaDescription );
+
+ // Update the schemaName
+ updateSchemaName( schemaObject );
+
+ return schemaObject;
+ }
+ catch ( RecognitionException re )
+ {
+ ParseException parseException = wrapRecognitionException( schemaDescription, re );
+ throw parseException;
+ }
+ catch ( TokenStreamRecognitionException tsre )
+ {
+ if ( tsre.recog != null )
+ {
+ ParseException parseException = wrapRecognitionException( schemaDescription, tsre.recog );
+ throw parseException;
+ }
+ else
+ {
+ ParseException parseException = wrapTokenStreamException( schemaDescription, tsre );
+ throw parseException;
+ }
+ }
+ catch ( TokenStreamException tse )
+ {
+ ParseException parseException = wrapTokenStreamException( schemaDescription, tse );
+ throw parseException;
+ }
+ }
+
+
+ private ParseException wrapRecognitionException( String schemaDescription, RecognitionException re )
+ {
+ String msg = I18n.err( errorCodeOnParseExceptionWithPosition, schemaDescription, re.getMessage(),
+ re.getColumn() );
+ LOG.error( msg );
+ ParseException parseException = new ParseException( msg, re.getColumn() );
+ parseException.initCause( re );
+ return parseException;
+ }
+
+
+ private ParseException wrapTokenStreamException( String schemaDescription, TokenStreamException tse )
+ {
+ String msg = I18n.err( errorCodeOnParseException, schemaDescription, tse.getMessage() );
+ LOG.error( msg );
+ ParseException parseException = new ParseException( msg, 0 );
+ parseException.initCause( tse );
+ return parseException;
+ }
+
+
+ /**
+ * Parse a SchemaObject description and returns back an instance of SchemaObject.
+ *
+ * @return A SchemaObject instance
+ * @throws RecognitionException the native antlr exception
+ * @throws TokenStreamException the native antlr exception
+ */
+ protected abstract T doParse() throws RecognitionException, TokenStreamException;
/**
@@ -125,7 +229,7 @@ public abstract class AbstractSchemaPars
*
* @param schemaObject the schema object where the name should be updated
*/
- protected static void updateSchemaName( SchemaObject schemaObject )
+ private void updateSchemaName( SchemaObject schemaObject )
{
// Update the Schema if we have the X-SCHEMA extension
List<String> schemaExtension = schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA_AT );
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AttributeTypeDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AttributeTypeDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AttributeTypeDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AttributeTypeDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,12 +24,9 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.AttributeType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
-import antlr.TokenStreamRecognitionException;
/**
@@ -37,17 +34,16 @@ import antlr.TokenStreamRecognitionExcep
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser
+public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser<AttributeType>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( AttributeTypeDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public AttributeTypeDescriptionSchemaParser()
{
+ super( AttributeType.class, I18n.ERR_04227, I18n.ERR_04228, I18n.ERR_04229 );
+
}
@@ -84,60 +80,19 @@ public class AttributeTypeDescriptionSch
* @return the parsed AttributeTypeDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized AttributeType parseAttributeTypeDescription( String attributeTypeDescription )
- throws ParseException
+ public AttributeType parseAttributeTypeDescription( String attributeTypeDescription ) throws ParseException
{
-
- LOG.debug( "Parsing an AttributeType : {}", attributeTypeDescription );
-
- if ( attributeTypeDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04227 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( attributeTypeDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- AttributeType attributeType = parser.attributeTypeDescription();
-
- // Update the schemaName
- updateSchemaName( attributeType );
-
- return attributeType;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04228, attributeTypeDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamRecognitionException tsre )
- {
- String msg = I18n.err( I18n.ERR_04229, attributeTypeDescription, tsre.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04229, attributeTypeDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( attributeTypeDescription );
}
/**
- * Parses a AttributeType description.
- *
- * @param schemaDescription The AttributeType description to parse
- * @return An instance of AttributeType
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public AttributeType parse( String schemaDescription ) throws ParseException
+ @Override
+ protected AttributeType doParse() throws RecognitionException, TokenStreamException
{
- return parseAttributeTypeDescription( schemaDescription );
+ return parser.attributeTypeDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitContentRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitContentRuleDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitContentRuleDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitContentRuleDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,29 +24,25 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.DitContentRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
/**
- * A parser for RFC 4512 DIT content rule descriptons
+ * A parser for RFC 4512 DIT content rule descriptions.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class DitContentRuleDescriptionSchemaParser extends AbstractSchemaParser
+public class DitContentRuleDescriptionSchemaParser extends AbstractSchemaParser<DitContentRule>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( DitContentRuleDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public DitContentRuleDescriptionSchemaParser()
{
+ super( DitContentRule.class, I18n.ERR_04230, I18n.ERR_04231, I18n.ERR_04232 );
}
@@ -70,53 +66,19 @@ public class DitContentRuleDescriptionSc
* @return the parsed DITContentRuleDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized DitContentRule parseDITContentRuleDescription( String ditContentRuleDescription )
- throws ParseException
+ public DitContentRule parseDITContentRuleDescription( String ditContentRuleDescription ) throws ParseException
{
- LOG.debug( "Parsing a DitContentRule : {}", ditContentRuleDescription );
-
- if ( ditContentRuleDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04230 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( ditContentRuleDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- DitContentRule ditContentRule = parser.ditContentRuleDescription();
-
- // Update the schemaName
- updateSchemaName( ditContentRule );
-
- return ditContentRule;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04231, ditContentRuleDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04232, ditContentRuleDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( ditContentRuleDescription );
}
/**
- * Parses a DitContentRule description.
- *
- * @param schemaDescription The DitContentRule description to parse
- * @return An instance of DitContentRule
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public DitContentRule parse( String schemaDescription ) throws ParseException
+ @Override
+ protected DitContentRule doParse() throws RecognitionException, TokenStreamException
{
- return parseDITContentRuleDescription( schemaDescription );
+ return parser.ditContentRuleDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitStructureRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitStructureRuleDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitStructureRuleDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/DitStructureRuleDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,30 +24,25 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.DitStructureRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
/**
- * A parser for RFC 4512 DIT structure rule descriptons
+ * A parser for RFC 4512 DIT structure rule descriptions.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class DitStructureRuleDescriptionSchemaParser extends AbstractSchemaParser
+public class DitStructureRuleDescriptionSchemaParser extends AbstractSchemaParser<DitStructureRule>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( DitStructureRuleDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public DitStructureRuleDescriptionSchemaParser()
{
- super();
+ super( DitStructureRule.class, I18n.ERR_04233, I18n.ERR_04234, I18n.ERR_04235 );
}
@@ -73,53 +68,20 @@ public class DitStructureRuleDescription
* @return the parsed DITStructureRuleDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized DitStructureRule parseDITStructureRuleDescription( String ditStructureRuleDescription )
+ public DitStructureRule parseDITStructureRuleDescription( String ditStructureRuleDescription )
throws ParseException
{
- LOG.debug( "Parsing a DitStructureRule : {}", ditStructureRuleDescription );
-
- if ( ditStructureRuleDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04233 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( ditStructureRuleDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- DitStructureRule ditStructureRule = parser.ditStructureRuleDescription();
-
- // Update the schemaName
- updateSchemaName( ditStructureRule );
-
- return ditStructureRule;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04234, ditStructureRuleDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04235, ditStructureRuleDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
+ return super.parse( ditStructureRuleDescription );
}
/**
- * Parses a DitStructureRule description.
- *
- * @param schemaDescription The DitStructureRule description to parse
- * @return An instance of DitStructureRule
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public DitStructureRule parse( String schemaDescription ) throws ParseException
+ @Override
+ protected DitStructureRule doParse() throws RecognitionException, TokenStreamException
{
- return parseDITStructureRuleDescription( schemaDescription );
+ return parser.ditStructureRuleDescription();
}
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapComparatorDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -23,8 +23,6 @@ package org.apache.directory.api.ldap.mo
import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -35,18 +33,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapComparatorDescriptionSchemaParser extends AbstractSchemaParser
+public class LdapComparatorDescriptionSchemaParser extends AbstractSchemaParser<LdapComparatorDescription>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( LdapComparatorDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public LdapComparatorDescriptionSchemaParser()
{
- super();
+ super( LdapComparatorDescription.class, I18n.ERR_04236, I18n.ERR_04237, I18n.ERR_04238 );
}
@@ -74,56 +69,19 @@ public class LdapComparatorDescriptionSc
* @return the parsed ComparatorDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public LdapComparatorDescription parseComparatorDescription( String comparatorDescription )
- throws ParseException
+ public LdapComparatorDescription parseComparatorDescription( String comparatorDescription ) throws ParseException
{
- LOG.debug( "Parsing a Comparator : {}", comparatorDescription );
-
- if ( comparatorDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04236 ) );
- throw new ParseException( "Null", 0 );
- }
-
- synchronized ( parser )
- {
- reset( comparatorDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- LdapComparatorDescription ldapComparatorDescription = parser.ldapComparator();
- LOG.debug( "Parsed a LdapComparator : {}", ldapComparatorDescription );
-
- // Update the schemaName
- updateSchemaName( ldapComparatorDescription );
-
- return ldapComparatorDescription;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04273, comparatorDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04238, comparatorDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
- }
+ return super.parse( comparatorDescription );
}
/**
- * Parses a LdapComparator description.
- *
- * @param schemaDescription The LdapComparator description to parse
- * @return An instance of LdapComparatorDescription
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public LdapComparatorDescription parse( String schemaDescription ) throws ParseException
+ @Override
+ protected LdapComparatorDescription doParse() throws RecognitionException, TokenStreamException
{
- return parseComparatorDescription( schemaDescription );
+ return parser.ldapComparator();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/LdapSyntaxDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,8 +24,6 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.LdapSyntax;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -36,17 +34,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapSyntaxDescriptionSchemaParser extends AbstractSchemaParser
+public class LdapSyntaxDescriptionSchemaParser extends AbstractSchemaParser<LdapSyntax>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( LdapSyntaxDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public LdapSyntaxDescriptionSchemaParser()
{
+ super( LdapSyntax.class, I18n.ERR_04239, I18n.ERR_04240, I18n.ERR_04241 );
}
@@ -64,53 +60,19 @@ public class LdapSyntaxDescriptionSchema
* @return the parsed LdapSyntax bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized LdapSyntax parseLdapSyntaxDescription( String ldapSyntaxDescription )
- throws ParseException
+ public LdapSyntax parseLdapSyntaxDescription( String ldapSyntaxDescription ) throws ParseException
{
- LOG.debug( "Parsing a LdapSyntax : {}", ldapSyntaxDescription );
-
- if ( ldapSyntaxDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04239 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( ldapSyntaxDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- LdapSyntax ldapSyntax = parser.ldapSyntaxDescription();
- ldapSyntax.setSpecification( ldapSyntaxDescription );
-
- // Update the schemaName
- updateSchemaName( ldapSyntax );
-
- return ldapSyntax;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04240, ldapSyntaxDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04241, ldapSyntaxDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
+ return super.parse( ldapSyntaxDescription );
}
/**
- * Parses a LdapSyntax description.
- *
- * @param schemaDescription The LdapSyntax description to parse
- * @return An instance of LdapSyntax
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public LdapSyntax parse( String schemaDescription ) throws ParseException
+ @Override
+ protected LdapSyntax doParse() throws RecognitionException, TokenStreamException
{
- return parseLdapSyntaxDescription( schemaDescription );
+ return parser.ldapSyntaxDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,8 +24,6 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.MatchingRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -36,17 +34,14 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class MatchingRuleDescriptionSchemaParser extends AbstractSchemaParser
+public class MatchingRuleDescriptionSchemaParser extends AbstractSchemaParser<MatchingRule>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( MatchingRuleDescriptionSchemaParser.class );
-
-
/**
* Creates a schema parser instance.
*/
public MatchingRuleDescriptionSchemaParser()
{
+ super( MatchingRule.class, I18n.ERR_04242, I18n.ERR_04243, I18n.ERR_04244 );
}
@@ -70,52 +65,19 @@ public class MatchingRuleDescriptionSche
* @return the parsed MatchingRuleDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized MatchingRule parseMatchingRuleDescription( String matchingRuleDescription )
- throws ParseException
+ public MatchingRule parseMatchingRuleDescription( String matchingRuleDescription ) throws ParseException
{
- LOG.debug( "Parsing a MatchingRule : {}", matchingRuleDescription );
-
- if ( matchingRuleDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04242 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( matchingRuleDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- MatchingRule matchingRule = parser.matchingRuleDescription();
-
- // Update the schemaName
- updateSchemaName( matchingRule );
-
- return matchingRule;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04243, matchingRuleDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04244, matchingRuleDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
+ return super.parse( matchingRuleDescription );
}
/**
- * Parses a MatchingRule description.
- *
- * @param schemaDescription The MatchingRule description to parse
- * @return An instance of MatchingRule
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public MatchingRule parse( String schemaDescription ) throws ParseException
+ @Override
+ protected MatchingRule doParse() throws RecognitionException, TokenStreamException
{
- return parseMatchingRuleDescription( schemaDescription );
+ return parser.matchingRuleDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleUseDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleUseDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleUseDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/MatchingRuleUseDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,8 +24,6 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.MatchingRuleUse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -36,17 +34,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class MatchingRuleUseDescriptionSchemaParser extends AbstractSchemaParser
+public class MatchingRuleUseDescriptionSchemaParser extends AbstractSchemaParser<MatchingRuleUse>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( MatchingRuleUseDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public MatchingRuleUseDescriptionSchemaParser()
{
+ super( MatchingRuleUse.class, I18n.ERR_04245, I18n.ERR_04246, I18n.ERR_04247 );
}
@@ -70,53 +66,19 @@ public class MatchingRuleUseDescriptionS
* @return the parsed MatchingRuleUseDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized MatchingRuleUse parseMatchingRuleUseDescription( String matchingRuleUseDescription )
- throws ParseException
+ public MatchingRuleUse parseMatchingRuleUseDescription( String matchingRuleUseDescription ) throws ParseException
{
- LOG.debug( "Parsing a MatchingRuleUse : {}", matchingRuleUseDescription );
-
- if ( matchingRuleUseDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04245 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( matchingRuleUseDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- MatchingRuleUse matchingRuleUse = parser.matchingRuleUseDescription();
-
- // Update the schemaName
- updateSchemaName( matchingRuleUse );
-
- return matchingRuleUse;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04246, matchingRuleUseDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04247, matchingRuleUseDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( matchingRuleUseDescription );
}
/**
- * Parses a MatchingRuleUse description.
- *
- * @param schemaDescription The MatchingRuleUse description to parse
- * @return An instance of MatchingRuleUse
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public MatchingRuleUse parse( String schemaDescription ) throws ParseException
+ @Override
+ protected MatchingRuleUse doParse() throws RecognitionException, TokenStreamException
{
- return parseMatchingRuleUseDescription( schemaDescription );
+ return parser.matchingRuleUseDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NameFormDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NameFormDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NameFormDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NameFormDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -24,8 +24,6 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.NameForm;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -36,17 +34,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class NameFormDescriptionSchemaParser extends AbstractSchemaParser
+public class NameFormDescriptionSchemaParser extends AbstractSchemaParser<NameForm>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( NameFormDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public NameFormDescriptionSchemaParser()
{
+ super( NameForm.class, I18n.ERR_04248, I18n.ERR_04249, I18n.ERR_04250 );
}
@@ -69,52 +65,19 @@ public class NameFormDescriptionSchemaPa
* @return the parsed NameForm bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized NameForm parseNameFormDescription( String nameFormDescription )
- throws ParseException
+ public NameForm parseNameFormDescription( String nameFormDescription ) throws ParseException
{
- LOG.debug( "Parsing a NameForm : {}", nameFormDescription );
-
- if ( nameFormDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04248 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( nameFormDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- NameForm nameForm = parser.nameFormDescription();
-
- // Update the schemaName
- updateSchemaName( nameForm );
-
- return nameForm;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04249, nameFormDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04250, nameFormDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
+ return super.parse( nameFormDescription );
}
/**
- * Parses a NameForm description.
- *
- * @param schemaDescription The NameForm description to parse
- * @return An instance of NameForm
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public NameForm parse( String schemaDescription ) throws ParseException
+ @Override
+ protected NameForm doParse() throws RecognitionException, TokenStreamException
{
- return parseNameFormDescription( schemaDescription );
+ return parser.nameFormDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/NormalizerDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -23,8 +23,6 @@ package org.apache.directory.api.ldap.mo
import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -35,18 +33,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class NormalizerDescriptionSchemaParser extends AbstractSchemaParser
+public class NormalizerDescriptionSchemaParser extends AbstractSchemaParser<NormalizerDescription>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( NormalizerDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public NormalizerDescriptionSchemaParser()
{
- super();
+ super( NormalizerDescription.class, I18n.ERR_04251, I18n.ERR_04252, I18n.ERR_04253 );
}
@@ -74,53 +69,16 @@ public class NormalizerDescriptionSchema
* @return the parsed NormalizerDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized NormalizerDescription parseNormalizerDescription( String normalizerDescription )
- throws ParseException
+ public NormalizerDescription parseNormalizerDescription( String normalizerDescription ) throws ParseException
{
- LOG.debug( "Parsing a Normalizer : {}", normalizerDescription );
-
- if ( normalizerDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04251 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( normalizerDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- NormalizerDescription normalizer = parser.normalizerDescription();
-
- // Update the schemaName
- updateSchemaName( normalizer );
-
- return normalizer;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04252, normalizerDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04253, normalizerDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( normalizerDescription );
}
- /**
- * Parses a Normalizer description.
- *
- * @param schemaDescription The Normalizer description to parse
- * @return An instance of NormalizerDescription
- * @throws ParseException {@inheritDoc}
- */
- public NormalizerDescription parse( String schemaDescription ) throws ParseException
+ @Override
+ protected NormalizerDescription doParse() throws RecognitionException, TokenStreamException
{
- return parseNormalizerDescription( schemaDescription );
+ return parser.normalizerDescription();
}
+
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ObjectClassDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ObjectClassDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ObjectClassDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ObjectClassDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -25,8 +25,6 @@ import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.schema.MutableObjectClass;
import org.apache.directory.api.ldap.model.schema.ObjectClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -37,18 +35,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ObjectClassDescriptionSchemaParser extends AbstractSchemaParser
+public class ObjectClassDescriptionSchemaParser extends AbstractSchemaParser<ObjectClass>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( ObjectClassDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public ObjectClassDescriptionSchemaParser()
{
- // Nothing to do
+ super( ObjectClass.class, I18n.ERR_04254, I18n.ERR_04255, I18n.ERR_04256 );
}
@@ -77,54 +72,19 @@ public class ObjectClassDescriptionSchem
* @return the parsed ObjectClassDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized MutableObjectClass parseObjectClassDescription( String objectClassDescription )
- throws ParseException
+ public ObjectClass parseObjectClassDescription( String objectClassDescription ) throws ParseException
{
- LOG.debug( "Parsing an ObjectClass : {}", objectClassDescription );
-
- if ( objectClassDescription == null )
- {
- LOG.error( I18n.err( I18n.ERR_04254 ) );
- throw new ParseException( "Null", 0 );
- }
-
- reset( objectClassDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- MutableObjectClass objectClass = parser.objectClassDescription();
-
- // Update the schemaName
- updateSchemaName( objectClass );
-
- return objectClass;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04255, objectClassDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04256, objectClassDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( objectClassDescription );
}
/**
- * Parses a ObjectClass description.
- *
- * @param schemaDescription The ObjectClass description to parse
- * @return An instance of ObjectClass
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public ObjectClass parse( String schemaDescription ) throws ParseException
+ @Override
+ protected ObjectClass doParse() throws RecognitionException, TokenStreamException
{
- return parseObjectClassDescription( schemaDescription );
+ return parser.objectClassDescription();
}
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -48,7 +48,7 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class OpenLdapSchemaParser extends AbstractSchemaParser
+public class OpenLdapSchemaParser extends AbstractSchemaParser<SchemaObject>
{
/** The list of parsed schema descriptions */
@@ -74,11 +74,19 @@ public class OpenLdapSchemaParser extend
*/
public OpenLdapSchemaParser() throws IOException
{
+ super( null, null, null, null );
isResolveObjectIdentifierMacros = true;
super.setQuirksMode( true );
}
+ @Override
+ protected SchemaObject doParse() throws RecognitionException, TokenStreamException
+ {
+ throw new UnsupportedOperationException( "OpenLdapSchemaParser is not a normal schema parser" );
+ }
+
+
/**
* Reset the parser
*/
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java?rev=1661442&r1=1661441&r2=1661442&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/SyntaxCheckerDescriptionSchemaParser.java Sat Feb 21 21:41:00 2015
@@ -23,8 +23,6 @@ package org.apache.directory.api.ldap.mo
import java.text.ParseException;
import org.apache.directory.api.i18n.I18n;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import antlr.RecognitionException;
import antlr.TokenStreamException;
@@ -35,18 +33,15 @@ import antlr.TokenStreamException;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class SyntaxCheckerDescriptionSchemaParser extends AbstractSchemaParser
+public class SyntaxCheckerDescriptionSchemaParser extends AbstractSchemaParser<SyntaxCheckerDescription>
{
- /** The LoggerFactory used by this class */
- protected static final Logger LOG = LoggerFactory.getLogger( SyntaxCheckerDescriptionSchemaParser.class );
-
/**
* Creates a schema parser instance.
*/
public SyntaxCheckerDescriptionSchemaParser()
{
- super();
+ super( SyntaxCheckerDescription.class, I18n.ERR_04258, I18n.ERR_04259, I18n.ERR_04260 );
}
@@ -74,52 +69,20 @@ public class SyntaxCheckerDescriptionSch
* @return the parsed SyntaxCheckerDescription bean
* @throws ParseException if there are any recognition errors (bad syntax)
*/
- public synchronized SyntaxCheckerDescription parseSyntaxCheckerDescription( String syntaxCheckerDescription )
+ public SyntaxCheckerDescription parseSyntaxCheckerDescription( String syntaxCheckerDescription )
throws ParseException
{
- LOG.debug( "Parsing a SyntaxChecker : {}", syntaxCheckerDescription );
-
- if ( syntaxCheckerDescription == null )
- {
- throw new ParseException( "Null", 0 );
- }
-
- reset( syntaxCheckerDescription ); // reset and initialize the parser / lexer pair
-
- try
- {
- SyntaxCheckerDescription syntaxChecker = parser.syntaxCheckerDescription();
-
- // Update the schemaName
- updateSchemaName( syntaxChecker );
-
- return syntaxChecker;
- }
- catch ( RecognitionException re )
- {
- String msg = I18n.err( I18n.ERR_04259, syntaxCheckerDescription, re.getMessage(), re.getColumn() );
- LOG.error( msg );
- throw new ParseException( msg, re.getColumn() );
- }
- catch ( TokenStreamException tse )
- {
- String msg = I18n.err( I18n.ERR_04260, syntaxCheckerDescription, tse.getMessage() );
- LOG.error( msg );
- throw new ParseException( msg, 0 );
- }
-
+ return super.parse( syntaxCheckerDescription );
}
/**
- * Parses a SyntaxChecker description
- *
- * @param schemaDescription The SyntaxChecker description to parse
- * @return An instance of SyntaxCheckerDescription
- * @throws ParseException {@inheritDoc}
+ * {@inheritDoc}
*/
- public SyntaxCheckerDescription parse( String schemaDescription ) throws ParseException
+ @Override
+ protected SyntaxCheckerDescription doParse() throws RecognitionException, TokenStreamException
{
- return parseSyntaxCheckerDescription( schemaDescription );
+ return parser.syntaxCheckerDescription();
}
+
}