directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r359026 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java
Date Mon, 26 Dec 2005 00:38:15 GMT
Author: elecharny
Date: Sun Dec 25 16:38:10 2005
New Revision: 359026

URL: http://svn.apache.org/viewcvs?rev=359026&view=rev
Log:
We now use the DnParser instead of a local parser
initialized in the constructor.

Modified:
    directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java?rev=359026&r1=359025&r2=359026&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnSyntaxChecker.java
Sun Dec 25 16:38:10 2005
@@ -18,7 +18,6 @@
 
 
 import javax.naming.Name;
-import javax.naming.NameParser;
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.name.DnParser;
@@ -28,55 +27,31 @@
  * A distinguished name syntax checker.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$
  */
 public class DnSyntaxChecker implements SyntaxChecker
 {
-    /** The oid of the checked syntax */ 
-    private final String oid ;
-    /** The parser used to parse the DN */
-    private NameParser parser ;
-    
-    
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R S
-    // ------------------------------------------------------------------------
+    /** the OID of the Syntax this checker is associated with */
+    private final String oid;
 
 
     /**
-     * Creates a SyntaxChecker for a DN based Syntax that uses a distinguished 
-     * name parser.
-     * 
-     * @param oid the OID of the syntax
+     * Creates a SyntaxChecker which accepts all values.
+     *
+     * @param oid the oid of the Syntax this checker is associated with
      */
-    public DnSyntaxChecker( String oid ) throws NamingException
+    public DnSyntaxChecker( String oid )
     {
-        this.oid = oid ;
-
-        /*
-         * One may ask: why are we not taking the same measures here to
-         * introduce a name component normalizer? The answer to this is
-         * well we don't care what the value of an attribute assertion is
-         * we only care that the DN containing it is properly formed.
-         */
-        parser = new DnParser() ;
+        this.oid = oid;
     }
 
-
-    // ------------------------------------------------------------------------
-    // SyntaxChecker Methods
-    // ------------------------------------------------------------------------
-
-
     /**
-     * @see org.apache.ldap.common.schema.SyntaxChecker#getSyntaxOid()
+     * @see SyntaxChecker#getSyntaxOid()
      */
-    public String getSyntaxOid() 
+    public String getSyntaxOid()
     {
-        return oid ;
+        return oid;
     }
 
-
     /**
      * @see org.apache.ldap.common.schema.SyntaxChecker#isValidSyntax(Object)
      */
@@ -90,7 +65,7 @@
         {
             try
             {
-                parser.parse( ( String ) value ) ;
+                DnParser.getNameParser().parse( ( String ) value ) ;
             }
             catch ( Exception e )
             {
@@ -115,10 +90,18 @@
         }
         else if ( value instanceof String )
         {
-            parser.parse( ( String ) value ) ;
+            DnParser.getNameParser().parse( ( String ) value ) ;
         }
         
         throw new NamingException( "Do not know how syntax check instances of " 
             + value.getClass() ) ;
+    }
+
+    /**
+     * A String representation of this class
+     */
+    public String toString()
+    {
+    	return "DnSyntaxChecker : " + oid;
     }
 }



Mime
View raw message