directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r504368 - in /directory/shared/trunk/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/syntax/ main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ test/java/org/apache/directory/shared/ldap/schema/syntax/
Date Tue, 06 Feb 2007 23:34:49 GMT
Author: seelmann
Date: Tue Feb  6 15:34:48 2007
New Revision: 504368

URL: http://svn.apache.org/viewvc?view=rev&rev=504368
Log:
Added ApacheDS specific schema description parsers and beans:
o Comparator
o Normalizer
o SyntaxChecker

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractAdsSchemaDescription.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ComparatorDescription.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NormalizerDescription.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/SyntaxCheckerDescription.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParser.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserComparatorDescriptionTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserNormalizerDescriptionTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserSyntaxCheckerDescriptionTest.java
Modified:
    directory/shared/trunk/ldap/src/main/antlr/schema.g

Modified: directory/shared/trunk/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/schema.g?view=diff&rev=504368&r1=504367&r2=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/schema.g Tue Feb  6 15:34:48 2007
@@ -79,11 +79,46 @@
 SYNTAX : ( "SYNTAX" WHSP syntax:VALUES (len:LEN)? ) { setText(syntax.getText().trim() + (len!=null?len.getText().trim():""));
} ;
 APPLIES : ( "APPLIES" WHSP applies:VALUES ) { setText(applies.getText().trim()); } ;
 EXTENSION : x:( "X-" ( 'a'..'z' | 'A'..'Z' | '-' | '_' )+ WHSP VALUES ) ; 
+FQCN : ( "FQCN" WHSP fqcn:FQCN_VALUE ) { setText(fqcn.getText().trim()); } ;
+BYTECODE : ( "BYTECODE" WHSP bytecode:BYTECODE_VALUE ) { setText(bytecode.getText().trim());
} ;
 
 protected VALUES : ( VALUE | LPAR  VALUE ( (DOLLAR)? VALUE )* RPAR ) ;
 protected VALUE : (WHSP)? ( QUOTED_STRING | UNQUOTED_STRING ) (options {greedy=true;}: WHSP)?
;
 protected UNQUOTED_STRING : (options{greedy=true;}: 'a'..'z' | 'A'..'Z' | '0'..'9' | '-'
| ';' | '.' )+ ;
 protected QUOTED_STRING : ( QUOTE (~'\'')* QUOTE ) ;
+protected FQCN_VALUE : ( FQCN_IDENTIFIER ( '.' FQCN_IDENTIFIER )* ) ;
+protected FQCN_IDENTIFIER : ( FQCN_LETTER ( FQCN_LETTERORDIGIT )* ) ;
+protected FQCN_LETTER : 
+       '\u0024' |
+       '\u0041'..'\u005a' |
+       '\u005f' |
+       '\u0061'..'\u007a' |
+       '\u00c0'..'\u00d6' |
+       '\u00d8'..'\u00f6' |
+       '\u00f8'..'\u00ff' |
+       '\u0100'..'\u1fff' |
+       '\u3040'..'\u318f' |
+       '\u3300'..'\u337f' |
+       '\u3400'..'\u3d2d' |
+       '\u4e00'..'\u9fff' |
+       '\uf900'..'\ufaff' ;
+protected FQCN_LETTERORDIGIT : 
+       '\u0024' |
+       '\u0041'..'\u005a' |
+       '\u005f' |
+       '\u0061'..'\u007a' |
+       '\u00c0'..'\u00d6' |
+       '\u00d8'..'\u00f6' |
+       '\u00f8'..'\u00ff' |
+       '\u0100'..'\u1fff' |
+       '\u3040'..'\u318f' |
+       '\u3300'..'\u337f' |
+       '\u3400'..'\u3d2d' |
+       '\u4e00'..'\u9fff' |
+       '\uf900'..'\ufaff' |
+       '\u0030'..'\u0039' ;
+protected BYTECODE_VALUE : ( 'a'..'z' | 'A'..'Z' | '0'..'9' | '+' | '/' | '=' )+ ;
+
 
 USAGE : ( "USAGE" (WHSP)? ) ;
 USER_APPLICATIONS : ( "userApplications" (WHSP)? ) ;
@@ -579,6 +614,162 @@
         //{
         //    throw new SemanticException( "MUST and MAY must be disjoint, "+aList.get( 0
)+" appears in both", null, 0, 0 );
         //}
+    }
+    ;
+    
+
+    /**
+     * Production for comparator descriptions. It is fault-tolerant
+     * against element ordering.
+     *
+     * <pre>
+     * ComparatorDescription = LPAREN WSP
+     *       numericoid                           ; object identifier
+     *       [ SP "DESC" SP qdstring ]            ; description
+     *       SP "FQCN" SP fqcn                    ; fully qualified class name
+     *       [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *       extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * </pre>
+    */
+comparatorDescription returns [ComparatorDescription cd = new ComparatorDescription()]
+    {
+        ElementTracker et = new ElementTracker();
+    }
+    :
+    ( oid:STARTNUMERICOID { cd.setNumericOid(numericoid(oid.getText())); } )
+    (
+	    ( desc:DESC { et.track("DESC", desc); cd.setDescription(qdstring(desc.getText())); }
)
+	    |
+	    ( fqcn:FQCN { et.track("FQCN", fqcn); cd.setFqcn(fqcn.getText()); } )
+	    |
+	    ( bytecode:BYTECODE { et.track("BYTECODE", bytecode); cd.setBytecode(bytecode.getText());
} )
+	    |
+	    ( extension:EXTENSION { 
+	        Extension ex = extension(extension.getText());
+	        et.track(ex.key, extension); 
+	        cd.addExtension(ex.key, ex.values); 
+	     } )
+    )*
+    RPAR
+    {
+        // semantic check: required elements
+        if( !et.contains("FQCN") ) {
+            throw new SemanticException( "FQCN is required", null, 0, 0 );
+        }
+        
+        // semantic check: length should be divisible by 4
+        if( cd.getBytecode() != null && ( cd.getBytecode().length() % 4 != 0 ) )
{
+            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+        }
+    }
+    ;
+    
+
+    /**
+     * Production for normalizer descriptions. It is fault-tolerant
+     * against element ordering.
+     *
+     * <pre>
+     * NormalizerDescription = LPAREN WSP
+     *       numericoid                           ; object identifier
+     *       [ SP "DESC" SP qdstring ]            ; description
+     *       SP "FQCN" SP fqcn                    ; fully qualified class name
+     *       [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *       extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * </pre>
+    */
+normalizerDescription returns [NormalizerDescription nd = new NormalizerDescription()]
+    {
+        ElementTracker et = new ElementTracker();
+    }
+    :
+    ( oid:STARTNUMERICOID { nd.setNumericOid(numericoid(oid.getText())); } )
+    (
+	    ( desc:DESC { et.track("DESC", desc); nd.setDescription(qdstring(desc.getText())); }
)
+	    |
+	    ( fqcn:FQCN { et.track("FQCN", fqcn); nd.setFqcn(fqcn.getText()); } )
+	    |
+	    ( bytecode:BYTECODE { et.track("BYTECODE", bytecode); nd.setBytecode(bytecode.getText());
} )
+	    |
+	    ( extension:EXTENSION { 
+	        Extension ex = extension(extension.getText());
+	        et.track(ex.key, extension); 
+	        nd.addExtension(ex.key, ex.values); 
+	     } )
+    )*
+    RPAR
+    {
+        // semantic check: required elements
+        if( !et.contains("FQCN") ) {
+            throw new SemanticException( "FQCN is required", null, 0, 0 );
+        }
+        
+        // semantic check: length should be divisible by 4
+        if( nd.getBytecode() != null && ( nd.getBytecode().length() % 4 != 0 ) )
{
+            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+        }        
+    }
+    ;
+    
+
+    /**
+     * Production for syntax checker descriptions. It is fault-tolerant
+     * against element ordering.
+     *
+     * <pre>
+     * SyntaxCheckerDescription = LPAREN WSP
+     *       numericoid                           ; object identifier
+     *       [ SP "DESC" SP qdstring ]            ; description
+     *       SP "FQCN" SP fqcn                    ; fully qualified class name
+     *       [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *       extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * </pre>
+    */
+syntaxCheckerDescription returns [SyntaxCheckerDescription scd = new SyntaxCheckerDescription()]
+    {
+        ElementTracker et = new ElementTracker();
+    }
+    :
+    ( oid:STARTNUMERICOID { scd.setNumericOid(numericoid(oid.getText())); } )
+    (
+	    ( desc:DESC { et.track("DESC", desc); scd.setDescription(qdstring(desc.getText()));
} )
+	    |
+	    ( fqcn:FQCN { et.track("FQCN", fqcn); scd.setFqcn(fqcn.getText()); } )
+	    |
+	    ( bytecode:BYTECODE { et.track("BYTECODE", bytecode); scd.setBytecode(bytecode.getText());
} )
+	    |
+	    ( extension:EXTENSION { 
+	        Extension ex = extension(extension.getText());
+	        et.track(ex.key, extension); 
+	        scd.addExtension(ex.key, ex.values); 
+	     } )
+    )*
+    RPAR
+    {
+        // semantic check: required elements
+        if( !et.contains("FQCN") ) {
+            throw new SemanticException( "FQCN is required", null, 0, 0 );
+        }
+        
+        // semantic check: length should be divisible by 4
+        if( scd.getBytecode() != null && ( scd.getBytecode().length() % 4 != 0 )
) {
+            throw new SemanticException( "BYTECODE must be divisible by 4", null, 0, 0 );
+        }        
     }
     ;
     

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractAdsSchemaDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractAdsSchemaDescription.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractAdsSchemaDescription.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/AbstractAdsSchemaDescription.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+/**
+ * An ApacheDS specific schema description. 
+ * It contains a full qualified class name and optional 
+ * the BASE64 encoded bytecode of the class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractAdsSchemaDescription extends AbstractSchemaDescription
+{
+
+    private String fqcn;
+
+    private String bytecode;
+
+
+    protected AbstractAdsSchemaDescription()
+    {
+        fqcn = "";
+        bytecode = null;
+    }
+
+
+    public String getBytecode()
+    {
+        return bytecode;
+    }
+
+
+    public void setBytecode( String bytecode )
+    {
+        this.bytecode = bytecode;
+    }
+
+
+    public String getFqcn()
+    {
+        return fqcn;
+    }
+
+
+    public void setFqcn( String fqcn )
+    {
+        this.fqcn = fqcn;
+    }
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ComparatorDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ComparatorDescription.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ComparatorDescription.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ComparatorDescription.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+/**
+ * An ApacheDS specific schema description.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComparatorDescription extends AbstractAdsSchemaDescription
+{
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NormalizerDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NormalizerDescription.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NormalizerDescription.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NormalizerDescription.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+/**
+ * An ApacheDS specific schema description.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NormalizerDescription extends AbstractAdsSchemaDescription
+{
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/SyntaxCheckerDescription.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/SyntaxCheckerDescription.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/SyntaxCheckerDescription.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/SyntaxCheckerDescription.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+/**
+ * An ApacheDS specific schema description.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SyntaxCheckerDescription extends AbstractAdsSchemaDescription
+{
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParser.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParser.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/ComparatorDescriptionSchemaParser.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,111 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A parser for ApacheDS comparator descriptions.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ComparatorDescriptionSchemaParser extends AbstractSchemaParser
+{
+
+    /**
+     * Creates a schema parser instance.
+     */
+    public ComparatorDescriptionSchemaParser()
+    {
+        super();
+    }
+
+
+    /**
+     * Parses an comparator description:
+     * 
+     * <pre>
+     * ComparatorDescription = LPAREN WSP
+     *     numericoid                           ; object identifier
+     *     [ SP "DESC" SP qdstring ]            ; description
+     *     SP "FQCN" SP fqcn                    ; fully qualified class name
+     *     [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *     extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * 
+     * extensions = *( SP xstring SP qdstrings )
+     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+     * </pre>
+     * 
+     * @param comparatorDescription the comparator description to be parsed
+     * @return the parsed ComparatorDescription bean
+     * @throws ParseException if there are any recognition errors (bad syntax)
+     */
+    public synchronized ComparatorDescription parseComparatorDescription( String comparatorDescription
)
+        throws ParseException
+    {
+
+        if ( comparatorDescription == null )
+        {
+            throw new ParseException( "Null", 0 );
+        }
+
+        reset( comparatorDescription ); // reset and initialize the parser / lexer pair
+
+        try
+        {
+            ComparatorDescription cd = parser.comparatorDescription();
+            return cd;
+        }
+        catch ( RecognitionException re )
+        {
+            String msg = "Parser failure on comparator description:\n\t" + comparatorDescription;
+            msg += "\nAntlr message: " + re.getMessage();
+            msg += "\nAntlr column: " + re.getColumn();
+            throw new ParseException( msg, re.getColumn() );
+        }
+        catch ( TokenStreamException tse )
+        {
+            String msg = "Parser failure on comparator description:\n\t" + comparatorDescription;
+            msg += "\nAntlr message: " + tse.getMessage();
+            throw new ParseException( msg, 0 );
+        }
+
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseComparatorDescription( schemaDescription );
+    }
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParser.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParser.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/NormalizerDescriptionSchemaParser.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,111 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A parser for ApacheDS normalizer descriptions.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NormalizerDescriptionSchemaParser extends AbstractSchemaParser
+{
+
+    /**
+     * Creates a schema parser instance.
+     */
+    public NormalizerDescriptionSchemaParser()
+    {
+        super();
+    }
+
+
+    /**
+     * Parses a normalizer description:
+     * 
+     * <pre>
+     * NormalizerDescription = LPAREN WSP
+     *     numericoid                           ; object identifier
+     *     [ SP "DESC" SP qdstring ]            ; description
+     *     SP "FQCN" SP fqcn                    ; fully qualified class name
+     *     [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *     extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * 
+     * extensions = *( SP xstring SP qdstrings )
+     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+     * </pre>
+     * 
+     * @param normalizerDescription the normalizer description to be parsed
+     * @return the parsed NormalizerDescription bean
+     * @throws ParseException if there are any recognition errors (bad syntax)
+     */
+    public synchronized NormalizerDescription parseNormalizerDescription( String normalizerDescription
)
+        throws ParseException
+    {
+
+        if ( normalizerDescription == null )
+        {
+            throw new ParseException( "Null", 0 );
+        }
+
+        reset( normalizerDescription ); // reset and initialize the parser / lexer pair
+
+        try
+        {
+            NormalizerDescription nd = parser.normalizerDescription();
+            return nd;
+        }
+        catch ( RecognitionException re )
+        {
+            String msg = "Parser failure on normalizer description:\n\t" + normalizerDescription;
+            msg += "\nAntlr message: " + re.getMessage();
+            msg += "\nAntlr column: " + re.getColumn();
+            throw new ParseException( msg, re.getColumn() );
+        }
+        catch ( TokenStreamException tse )
+        {
+            String msg = "Parser failure on normalizer description:\n\t" + normalizerDescription;
+            msg += "\nAntlr message: " + tse.getMessage();
+            throw new ParseException( msg, 0 );
+        }
+
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseNormalizerDescription( schemaDescription );
+    }
+
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParser.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParser.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParser.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,111 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax.parser;
+
+
+import java.text.ParseException;
+
+import org.apache.directory.shared.ldap.schema.syntax.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+
+
+/**
+ * A parser for ApacheDS syntax checker descriptions.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SyntaxCheckerDescriptionSchemaParser extends AbstractSchemaParser
+{
+
+    /**
+     * Creates a schema parser instance.
+     */
+    public SyntaxCheckerDescriptionSchemaParser()
+    {
+        super();
+    }
+
+
+    /**
+     * Parses a syntax checker description:
+     * 
+     * <pre>
+     * SyntaxCheckerDescription = LPAREN WSP
+     *     numericoid                           ; object identifier
+     *     [ SP "DESC" SP qdstring ]            ; description
+     *     SP "FQCN" SP fqcn                    ; fully qualified class name
+     *     [ SP "BYTECODE" SP base64 ]          ; optional base64 encoded bytecode
+     *     extensions WSP RPAREN                ; extensions
+     * 
+     * base64          = *(4base64-char)
+     * base64-char     = ALPHA / DIGIT / "+" / "/"
+     * fqcn = fqcnComponent 1*( DOT fqcnComponent )
+     * fqcnComponent = ???
+     * 
+     * extensions = *( SP xstring SP qdstrings )
+     * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
+     * </pre>
+     * 
+     * @param syntaxCheckerDescription the syntax checker description to be parsed
+     * @return the parsed SyntaxCheckerDescription bean
+     * @throws ParseException if there are any recognition errors (bad syntax)
+     */
+    public synchronized SyntaxCheckerDescription parseSyntaxCheckerDescription( String syntaxCheckerDescription
)
+        throws ParseException
+    {
+
+        if ( syntaxCheckerDescription == null )
+        {
+            throw new ParseException( "Null", 0 );
+        }
+
+        reset( syntaxCheckerDescription ); // reset and initialize the parser / lexer pair
+
+        try
+        {
+            SyntaxCheckerDescription scd = parser.syntaxCheckerDescription();
+            return scd;
+        }
+        catch ( RecognitionException re )
+        {
+            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription;
+            msg += "\nAntlr message: " + re.getMessage();
+            msg += "\nAntlr column: " + re.getColumn();
+            throw new ParseException( msg, re.getColumn() );
+        }
+        catch ( TokenStreamException tse )
+        {
+            String msg = "Parser failure on syntax checker description:\n\t" + syntaxCheckerDescription;
+            msg += "\nAntlr message: " + tse.getMessage();
+            throw new ParseException( msg, 0 );
+        }
+
+    }
+
+
+    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    {
+        return parseSyntaxCheckerDescription( schemaDescription );
+    }
+
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserComparatorDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserComparatorDescriptionTest.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserComparatorDescriptionTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserComparatorDescriptionTest.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,134 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.ComparatorDescriptionSchemaParser;
+
+
+/**
+ * Tests the ComparatorDescriptionSchemaParser class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaParserComparatorDescriptionTest extends TestCase
+{
+    /** the parser instance */
+    private ComparatorDescriptionSchemaParser parser;
+
+
+    protected void setUp() throws Exception
+    {
+        parser = new ComparatorDescriptionSchemaParser();
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        parser = null;
+    }
+
+
+    public void testNumericOid() throws Exception
+    {
+        SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testDescription() throws ParseException
+    {
+        SchemaParserTestUtils
+            .testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFqcn() throws ParseException
+    {
+
+        String value = null;
+        ComparatorDescription cd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
+        cd = parser.parseComparatorDescription( value );
+        assertNotNull( cd.getFqcn() );
+        assertEquals( "org.apache.directory.SimpleComparator", cd.getFqcn() );
+
+    }
+
+
+    public void testBytecode() throws ParseException
+    {
+
+        String value = null;
+        ComparatorDescription cd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====
)";
+        cd = parser.parseComparatorDescription( value );
+        assertNotNull( cd.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====",
cd.getBytecode() );
+
+    }
+
+
+    public void testExtensions() throws ParseException
+    {
+        SchemaParserTestUtils.testExtensions( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFull() throws ParseException
+    {
+    }
+
+
+    /**
+     * Test unique elements.
+     * 
+     * @throws ParseException
+     */
+    public void testUniqueElements()
+    {
+    }
+
+
+    /**
+     * Test required elements.
+     * 
+     * @throws ParseException
+     */
+    public void testRequiredElements() throws ParseException
+    {
+    }
+
+
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public void testMultiThreaded() throws Exception
+    {
+    }
+
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserNormalizerDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserNormalizerDescriptionTest.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserNormalizerDescriptionTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserNormalizerDescriptionTest.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,134 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.NormalizerDescriptionSchemaParser;
+
+
+/**
+ * Tests the NormalizerDescriptionSchemaParser class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaParserNormalizerDescriptionTest extends TestCase
+{
+    /** the parser instance */
+    private NormalizerDescriptionSchemaParser parser;
+
+
+    protected void setUp() throws Exception
+    {
+        parser = new NormalizerDescriptionSchemaParser();
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        parser = null;
+    }
+
+
+    public void testNumericOid() throws Exception
+    {
+        SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testDescription() throws ParseException
+    {
+        SchemaParserTestUtils
+            .testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFqcn() throws ParseException
+    {
+
+        String value = null;
+        NormalizerDescription nd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
+        nd = parser.parseNormalizerDescription( value );
+        assertNotNull( nd.getFqcn() );
+        assertEquals( "org.apache.directory.SimpleComparator", nd.getFqcn() );
+
+    }
+
+
+    public void testBytecode() throws ParseException
+    {
+
+        String value = null;
+        NormalizerDescription nd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====
)";
+        nd = parser.parseNormalizerDescription( value );
+        assertNotNull( nd.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====",
nd.getBytecode() );
+
+    }
+
+
+    public void testExtensions() throws ParseException
+    {
+        SchemaParserTestUtils.testExtensions( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFull() throws ParseException
+    {
+    }
+
+
+    /**
+     * Test unique elements.
+     * 
+     * @throws ParseException
+     */
+    public void testUniqueElements()
+    {
+    }
+
+
+    /**
+     * Test required elements.
+     * 
+     * @throws ParseException
+     */
+    public void testRequiredElements() throws ParseException
+    {
+    }
+
+
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public void testMultiThreaded() throws Exception
+    {
+    }
+
+}

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserSyntaxCheckerDescriptionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserSyntaxCheckerDescriptionTest.java?view=auto&rev=504368
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserSyntaxCheckerDescriptionTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/SchemaParserSyntaxCheckerDescriptionTest.java
Tue Feb  6 15:34:48 2007
@@ -0,0 +1,134 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.syntax;
+
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.shared.ldap.schema.syntax.parser.SyntaxCheckerDescriptionSchemaParser;
+
+
+/**
+ * Tests the SyntaxCheckerDescriptionSchemaParser class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaParserSyntaxCheckerDescriptionTest extends TestCase
+{
+    /** the parser instance */
+    private SyntaxCheckerDescriptionSchemaParser parser;
+
+
+    protected void setUp() throws Exception
+    {
+        parser = new SyntaxCheckerDescriptionSchemaParser();
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        parser = null;
+    }
+
+
+    public void testNumericOid() throws Exception
+    {
+        SchemaParserTestUtils.testNumericOid( parser, "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testDescription() throws ParseException
+    {
+        SchemaParserTestUtils
+            .testDescription( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFqcn() throws ParseException
+    {
+
+        String value = null;
+        SyntaxCheckerDescription scd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator )";
+        scd = parser.parseSyntaxCheckerDescription( value );
+        assertNotNull( scd.getFqcn() );
+        assertEquals( "org.apache.directory.SimpleComparator", scd.getFqcn() );
+
+    }
+
+
+    public void testBytecode() throws ParseException
+    {
+
+        String value = null;
+        SyntaxCheckerDescription scd = null;
+
+        // FQCN simple p
+        value = "( 1.1 FQCN org.apache.directory.SimpleComparator BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====
)";
+        scd = parser.parseSyntaxCheckerDescription( value );
+        assertNotNull( scd.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====",
scd.getBytecode() );
+
+    }
+
+
+    public void testExtensions() throws ParseException
+    {
+        SchemaParserTestUtils.testExtensions( parser, "1.1", "FQCN org.apache.directory.SimpleComparator"
);
+    }
+
+
+    public void testFull() throws ParseException
+    {
+    }
+
+
+    /**
+     * Test unique elements.
+     * 
+     * @throws ParseException
+     */
+    public void testUniqueElements()
+    {
+    }
+
+
+    /**
+     * Test required elements.
+     * 
+     * @throws ParseException
+     */
+    public void testRequiredElements() throws ParseException
+    {
+    }
+
+
+    /**
+     * Tests the multithreaded use of a single parser.
+     */
+    public void testMultiThreaded() throws Exception
+    {
+    }
+
+}



Mime
View raw message