directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r485820 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax: NumberSyntaxChecker.java NumericOidSyntaxChecker.java NumericStringSyntaxChecker.java ObjectClassDescriptionSyntaxChecker.java
Date Mon, 11 Dec 2006 19:04:15 GMT
Author: elecharny
Date: Mon Dec 11 11:04:14 2006
New Revision: 485820

URL: http://svn.apache.org/viewvc?view=rev&rev=485820
Log:
* Added the NumberSC used by the DitStructureRule RuleId element
* Modified the OID for NumericOid SC
* Fixed the javadoc for NumericString
* Move dthe creation of the SchemaParser into the constructor for OCDescription SC
* used the modified name of SchemaParser (now ObjectClassDescriptionShemaParser)

Added:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumberSyntaxChecker.java
Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericOidSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericStringSyntaxChecker.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxChecker.java

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumberSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumberSyntaxChecker.java?view=auto&rev=485820
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumberSyntaxChecker.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumberSyntaxChecker.java
Mon Dec 11 11:04:14 2006
@@ -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 javax.naming.NamingException;
+
+
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a Number according to RFC 4512.
+ * 
+ * From RFC 4512 :
+ * number  = DIGIT | ( LDIGIT 1*DIGIT )
+ * DIGIT   = %x30 | LDIGIT       ; "0"-"9"
+ * LDIGIT  = %x31-39             ; "1"-"9"
+ * 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class NumberSyntaxChecker implements SyntaxChecker
+{
+    /** The Syntax OID, according to RFC 4517, par. 3.3.23 */
+    public static final String OID = "1.3.6.1.4.1.18060.0.4.0.0.4";
+    
+    /**
+     * 
+     * Creates a new instance of NumberSyntaxChecker.
+     *
+     */
+    public NumberSyntaxChecker()
+    {
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#assertSyntax(java.lang.Object)
+     */
+    public void assertSyntax( Object value ) throws NamingException
+    {
+        if ( ! isValidSyntax( value ) )
+        {
+            throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX
);
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#getSyntaxOid()
+     */
+    public String getSyntaxOid()
+    {
+        return OID;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value ); 
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        // We should have at least one char
+        if ( strValue.length() == 0 )
+        {
+            return false;
+        }
+        
+        // Check that each char is either a digit or a space
+        for ( int i = 0; i < strValue.length(); i++ )
+        {
+            switch ( strValue.charAt( i ) )
+            {
+                case '0': 
+                case '1' :
+                case '2' :
+                case '3' :
+                case '4' :
+                case '5' :
+                case '6' :
+                case '7' :
+                case '8' :
+                case '9' :
+                    continue;
+                    
+                default : 
+                    return false;
+            }
+        }
+        
+        return true;
+    }
+}

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericOidSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericOidSyntaxChecker.java?view=diff&rev=485820&r1=485819&r2=485820
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericOidSyntaxChecker.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericOidSyntaxChecker.java
Mon Dec 11 11:04:14 2006
@@ -46,7 +46,7 @@
  */
 public class NumericOidSyntaxChecker implements SyntaxChecker
 {
-    public static final String DEFAULT_OID = "1.3.6.1.4.1.18060.0.4.0.0.0";
+    public static final String DEFAULT_OID = "1.3.6.1.4.1.18060.0.4.0.0.2";
     private final String oid;
     
     

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericStringSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericStringSyntaxChecker.java?view=diff&rev=485820&r1=485819&r2=485820
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericStringSyntaxChecker.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/NumericStringSyntaxChecker.java
Mon Dec 11 11:04:14 2006
@@ -36,7 +36,6 @@
  * NumericString = 1*(DIGIT / SPACE)
  * 
  * From RFC 4512 :
- * number  = DIGIT | ( LDIGIT 1*DIGIT )
  * DIGIT   = %x30 | LDIGIT       ; "0"-"9"
  * LDIGIT  = %x31-39             ; "1"-"9"
  * SPACE   = %x20                ; space (" ")

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxChecker.java?view=diff&rev=485820&r1=485819&r2=485820
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxChecker.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/ObjectClassDescriptionSyntaxChecker.java
Mon Dec 11 11:04:14 2006
@@ -26,6 +26,7 @@
 
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.syntax.parser.ObjectClassDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
@@ -60,7 +61,8 @@
     /** The Syntax OID, according to RFC 4517, par. 3.3.24 */
     public static final String OID = "1.3.6.1.4.1.1466.115.121.1.37";
 
-    private SchemaParser schemaParser;
+	/** The schema parser used to parse the ObjectClassDescription Syntax */
+    private ObjectClassDescriptionSchemaParser schemaParser = new ObjectClassDescriptionSchemaParser();
 
 
     /**
@@ -119,14 +121,10 @@
             strValue = value.toString();
         }
 
-        if ( schemaParser == null )
-        {
-            schemaParser = new SchemaParser();
-        }
-
         try
         {
             schemaParser.parseObjectClassDescription( strValue );
+                
             return true;
         }
         catch ( ParseException pe )



Mime
View raw message