You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2009/08/25 00:09:45 UTC

svn commit: r807408 - in /directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers: LdapSyntaxDescription.java NameFormDescription.java NameFormDescriptionSchemaParser.java ParserDescriptionUtils.java

Author: elecharny
Date: Mon Aug 24 22:09:44 2009
New Revision: 807408

URL: http://svn.apache.org/viewvc?rev=807408&view=rev
Log:
Rmobed the SyntaxChecker and NameForm Description classes.

Removed:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapSyntaxDescription.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescription.java
Modified:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescriptionSchemaParser.java?rev=807408&r1=807407&r2=807408&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescriptionSchemaParser.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NameFormDescriptionSchemaParser.java Mon Aug 24 22:09:44 2009
@@ -22,19 +22,26 @@
 
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
 
 
 /**
- * A parser for RFC 4512 name form descriptons
+ * A parser for RFC 4512 name form descriptions
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
 public class NameFormDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( NameFormDescriptionSchemaParser.class );
 
     /**
      * Creates a schema parser instance.
@@ -60,15 +67,22 @@
      * </pre>
      * 
      * @param nameFormDescription the name form description to be parsed
-     * @return the parsed NameFormDescription bean
+     * @return the parsed NameForm bean
      * @throws ParseException if there are any recognition errors (bad syntax)
      */
-    public synchronized NameFormDescription parseNameFormDescription( String nameFormDescription )
+    public synchronized NameForm parseNameFormDescription( String nameFormDescription )
+        throws ParseException
+    {
+        return parseNameFormDescription( nameFormDescription, null );
+    }
+
+    public synchronized NameForm parseNameFormDescription( String nameFormDescription, Registries registries )
         throws ParseException
     {
 
         if ( nameFormDescription == null )
         {
+            LOG.error( "Cannot parse a null NameForm" );
             throw new ParseException( "Null", 0 );
         }
 
@@ -76,29 +90,47 @@
 
         try
         {
-            NameFormDescription nfd = parser.nameFormDescription();
-            return nfd;
+            NameForm nf = parser.nameFormDescription( registries );
+            return nf;
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on name form description:\n\t" + nameFormDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on name form description:\n\t" + nameFormDescription +
+                "\nAntlr message: " + re.getMessage() +
+                "\nAntlr column: " + re.getColumn();
+            LOG.error( msg );
             throw new ParseException( msg, re.getColumn() );
         }
         catch ( TokenStreamException tse )
         {
-            String msg = "Parser failure on name form description:\n\t" + nameFormDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on name form description:\n\t" + nameFormDescription +
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
-
     }
 
 
-    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    /**
+     * Parses a NameForm description
+     * 
+     * @param The NameForm description to parse
+     * @return An instance of NameForm
+     */
+    public NameForm parse( String schemaDescription, Registries registries ) throws ParseException
     {
-        return parseNameFormDescription( schemaDescription );
+        return parseNameFormDescription( schemaDescription, registries );
     }
 
+
+    /**
+     * Parses a NameForm description
+     * 
+     * @param The NameForm description to parse
+     * @return An instance of NameForm
+     */
+    public NameForm parse( String schemaDescription ) throws ParseException
+    {
+        return parseNameFormDescription( schemaDescription, null );
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java?rev=807408&r1=807407&r2=807408&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java Mon Aug 24 22:09:44 2009
@@ -22,7 +22,9 @@
 
 import java.util.List;
 
+import org.apache.directory.shared.ldap.schema.LdapSyntax;
 import org.apache.directory.shared.ldap.schema.LoadableSchemaObject;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 
 
 
@@ -199,13 +201,13 @@
     /**
      * Checks to see if two syntax descriptions match exactly.
      *
-     * @param lsd0 the first syntax description to compare
-     * @param lsd1 the second syntax description to compare
+     * @param ldapSyntax0 the first ldapSyntax to compare
+     * @param ldapSyntax1 the second ldapSyntax to compare
      * @return true if the syntaxes match exactly, false otherwise
      */
-    public static boolean syntaxesMatch( LdapSyntaxDescription lsd0, LdapSyntaxDescription lsd1 )
+    public static boolean syntaxesMatch( LdapSyntax ldapSyntax0, LdapSyntax ldapSyntax1 )
     {
-        return descriptionsMatch( lsd0, lsd1 );
+        return descriptionsMatch( ldapSyntax0, ldapSyntax1 );
     }
     
     
@@ -219,37 +221,37 @@
      * @param lsd1 the second schema description to compare 
      * @return true if the descriptions match exactly, false otherwise
      */
-    public static boolean descriptionsMatch( LoadableSchemaObject lsd0, LoadableSchemaObject lsd1 )
+    public static boolean descriptionsMatch( SchemaObject so0, SchemaObject so1 )
     {
         // check that the OID matches
-        if ( ! lsd0.getOid().equals( lsd1.getOid() ) )
+        if ( ! so0.getOid().equals( so1.getOid() ) )
         {
             return false;
         }
         
         // check that the obsolete flag is equal but not for syntaxes
-        if ( ( lsd0 instanceof LdapSyntaxDescription ) || ( lsd1 instanceof LdapSyntaxDescription ) )
+        if ( ( so0 instanceof LdapSyntax ) || ( so1 instanceof LdapSyntax ) )
         {
-            if ( lsd0.isObsolete() != lsd1.isObsolete() )
+            if ( so0.isObsolete() != so1.isObsolete() )
             {
                 return false;
             }
         }
         
         // check that the description matches
-        if ( ! lsd0.getDescription().equals( lsd1.getDescription() ) )
+        if ( ! so0.getDescription().equals( so1.getDescription() ) )
         {
             return false;
         }
         
         // check alias names for exact match
-        if ( ! aliasNamesMatch( lsd0, lsd1 ) )
+        if ( ! aliasNamesMatch( so0, so1 ) )
         {
             return false;
         }
         
         // check extensions for exact match
-        if ( ! extensionsMatch( lsd0, lsd1 ) )
+        if ( ! extensionsMatch( so0, so1 ) )
         {
             return false;
         }