Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 29801 invoked from network); 24 Aug 2009 16:49:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Aug 2009 16:49:34 -0000 Received: (qmail 37794 invoked by uid 500); 24 Aug 2009 09:43:20 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 37733 invoked by uid 500); 24 Aug 2009 09:43:20 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 37724 invoked by uid 99); 24 Aug 2009 09:43:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Aug 2009 09:43:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Aug 2009 09:43:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 83E9D23888DC; Mon, 24 Aug 2009 09:42:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Mon, 24 Aug 2009 09:42:55 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090824094255.83E9D23888DC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 * */ -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 Apache Directory Project * @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 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(); } + /** + * @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 getSuperRules() { return superRules; } + /** + * Sets the list of superior RuleIds + * + * @param superRules the list of superior RuleIds + */ public void setSuperRules( List 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() );