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/24 11:42:55 UTC

svn commit: r807138 - in /directory/shared/branches/shared-schema/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/parsers/ test/java/org/apache/directory/shared/ldap/schema/syntax/parser/

Author: elecharny
Date: Mon Aug 24 09:42:54 2009
New Revision: 807138

URL: http://svn.apache.org/viewvc?rev=807138&view=rev
Log:
Added the DITStructureRule classes, many small fixes

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapComparatorDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NormalizerDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g Mon Aug 24 09:42:54 2009
@@ -665,13 +665,13 @@
      * ruleid = number
      * </pre>
     */
-ditStructureRuleDescription returns [DITStructureRuleDescription dsrd = new DITStructureRuleDescription()]
+ditStructureRuleDescription returns [DITStructureRuleDescription dsrd]
     {
         matchedProduction( "ditStructureRuleDescription()" );
         ElementTracker et = new ElementTracker();
     }
     :
-    ( ruleid:STARTNUMERICOID { dsrd.setRuleId(ruleid(ruleid.getText())); } )
+    ( ruleid:STARTNUMERICOID { dsrd = new DITStructureRuleDescription(ruleid(ruleid.getText())); } )
     (
         ( name:NAME { et.track("NAME", name); dsrd.setNames(qdescrs(name.getText())); } )
         |

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java Mon Aug 24 09:42:54 2009
@@ -24,6 +24,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
 
 /**
  * RFC 4512 - 4.1.7.  DIT Structure Rule Description
@@ -31,64 +35,109 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class DITStructureRuleDescription extends AbstractSchemaDescription
+public class DITStructureRuleDescription extends SchemaObject
 {
+    /** The serialVersionUID */
+    private static final long serialVersionUID = 1L;
 
-    private Integer ruleId;
+    /** The rule ID. A DSR does not have an OID */
+    private int ruleId;
     
+    /** The associated NameForm */
     private String form;
 
+    /** The list of superiors rules */
     private List<Integer> superRules;
 
 
-    public DITStructureRuleDescription()
+    /**
+     * Creates a new instance of DITStructureRuleDescription
+     */
+    public DITStructureRuleDescription( int ruleId )
     {
-        ruleId = 0;
+        super(  SchemaObjectType.DIT_STRUCTURE_RULE, null );
+        this.ruleId = ruleId;
         form = null;
         superRules = new ArrayList<Integer>();
     }
 
 
+    /**
+     *  @return The associated NameForm' OID
+     */
     public String getForm()
     {
         return form;
     }
 
 
+    /**
+     * Sets the associated NameForm's OID
+     *
+     * @param form The NameForm's OID
+     */
     public void setForm( String form )
     {
         this.form = form;
     }
 
 
-
-    public Integer getRuleId()
+    /**
+     * @return The Rule ID
+     */
+    public int getRuleId()
     {
         return ruleId;
     }
 
 
-    public void setRuleId( Integer ruleId )
+    /**
+     * Sets the rule identifier of this DIT structure rule;
+     *
+     * @param ruleId the rule identifier of this DIT structure rule;
+     */
+    public void setRuleId( int ruleId )
     {
         this.ruleId = ruleId;
     }
 
 
+    /**
+     * @return The list of superiors RuleIDs
+     */
     public List<Integer> getSuperRules()
     {
         return superRules;
     }
 
 
+    /**
+     * Sets the list of superior RuleIds
+     * 
+     * @param superRules the list of superior RuleIds
+     */
     public void setSuperRules( List<Integer> superRules )
     {
         this.superRules = superRules;
     }
 
-    
+
+    /**
+     * Adds a new superior RuleId
+     *
+     * @param superRule The superior RuleID to add
+     */
     public void addSuperRule( Integer superRule )
     {
         superRules.add( superRule );
     }
-
+    
+    
+    /**
+     * The DSR does not have an OID, so throw an exception
+     */
+    public String getOid()
+    {
+        throw new NotImplementedException(); 
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java Mon Aug 24 09:42:54 2009
@@ -22,6 +22,9 @@
 
 import java.text.ParseException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -35,12 +38,16 @@
  */
 public class DITStructureRuleDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( DITStructureRuleDescriptionSchemaParser.class );
+
 
     /**
      * Creates a schema parser instance.
      */
     public DITStructureRuleDescriptionSchemaParser()
     {
+        super();
     }
 
 
@@ -72,6 +79,7 @@
 
         if ( ditStructureRuleDescription == null )
         {
+            LOG.error( "Cannot parse a null DITStructureRule description" );
             throw new ParseException( "Null", 0 );
         }
 
@@ -84,24 +92,31 @@
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on DIT structure rule description:\n\t" + ditStructureRuleDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on DIT structure rule description:\n\t" + ditStructureRuleDescription +
+                "\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 DIT structure rule description:\n\t" + ditStructureRuleDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on DIT structure rule description:\n\t" + ditStructureRuleDescription +
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
 
     }
 
 
-    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    /**
+     * Parses a DITStructureRule description
+     * 
+     * @param The DITStructureRule description to parse
+     * @return An instance of SyntaxCheckerDescription
+     */
+    public DITStructureRuleDescription parse( String schemaDescription ) throws ParseException
     {
         return parseDITStructureRuleDescription( schemaDescription );
     }
-
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapComparatorDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapComparatorDescriptionSchemaParser.java?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapComparatorDescriptionSchemaParser.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/LdapComparatorDescriptionSchemaParser.java Mon Aug 24 09:42:54 2009
@@ -81,7 +81,7 @@
         
         if ( comparatorDescription == null )
         {
-            LOG.error( "Cannot parse a null string" );
+            LOG.error( "Cannot parse a null LdapComparator description" );
             throw new ParseException( "Null", 0 );
         }
 

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NormalizerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NormalizerDescriptionSchemaParser.java?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NormalizerDescriptionSchemaParser.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/NormalizerDescriptionSchemaParser.java Mon Aug 24 09:42:54 2009
@@ -22,6 +22,9 @@
 
 import java.text.ParseException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -35,12 +38,16 @@
  */
 public class NormalizerDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( NormalizerDescriptionSchemaParser.class );
+
 
     /**
      * Creates a schema parser instance.
      */
     public NormalizerDescriptionSchemaParser()
     {
+        super();
     }
 
 
@@ -74,6 +81,7 @@
 
         if ( normalizerDescription == null )
         {
+            LOG.error( "Cannot parse a null Normalizer description" );
             throw new ParseException( "Null", 0 );
         }
 
@@ -86,15 +94,17 @@
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on normalizer description:\n\t" + normalizerDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on normalizer description:\n\t" + normalizerDescription +
+                "\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 normalizer description:\n\t" + normalizerDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on normalizer description:\n\t" + normalizerDescription +
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
 

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=807138&r1=807137&r2=807138&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java Mon Aug 24 09:42:54 2009
@@ -96,17 +96,17 @@
         // simple
         value = "( 1 FORM 1.1 )";
         dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( new Integer( 1 ), dsrd.getRuleId() );
+        assertEquals( 1, dsrd.getRuleId() );
 
         // simple
         value = "( 1234567890 FORM 1.1 )";
         dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( new Integer( 1234567890 ), dsrd.getRuleId() );
+        assertEquals( 1234567890, dsrd.getRuleId() );
 
         // simple with spaces
         value = "(      1234567890   FORM   1.1     )";
         dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( new Integer( 1234567890 ), dsrd.getRuleId() );
+        assertEquals( 1234567890, dsrd.getRuleId() );
 
         // non-numeric not allowed
         value = "( test FORM 1.1 )";
@@ -359,9 +359,9 @@
         value = "( 1234567890 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' 'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE FORM 2.3.4.5.6.7.8.9.0.1 SUP ( 1 1234567890 5 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
         dsrd = parser.parseDITStructureRuleDescription( value );
 
-        assertEquals( new Integer( 1234567890 ), dsrd.getRuleId() );
+        assertEquals( 1234567890, dsrd.getRuleId() );
         assertEquals( 2, dsrd.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", dsrd.getNames().get( 0 ) );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-abcdefghijklmnopqrstuvwxyz-0123456789", dsrd.getNames().get( 0 ) );
         assertEquals( "test", dsrd.getNames().get( 1 ) );
         assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", dsrd.getDescription() );
         assertTrue( dsrd.isObsolete() );