directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r357152 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java
Date Fri, 16 Dec 2005 11:47:39 GMT
Author: elecharny
Date: Fri Dec 16 03:47:25 2005
New Revision: 357152

URL: http://svn.apache.org/viewcvs?rev=357152&view=rev
Log:
Renamed

Added:
    directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java
      - copied, changed from r356646, directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnNormalizer.java

Copied: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java
(from r356646, directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnNormalizer.java)
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java?p2=directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java&p1=directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnNormalizer.java&r1=356646&r2=357152&rev=357152&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DnNormalizer.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/schema/DNNormalizer.java
Fri Dec 16 03:47:25 2005
@@ -17,13 +17,14 @@
 package org.apache.ldap.common.schema;
 
 
+import java.util.Enumeration;
+
 import javax.naming.Name ;
-import javax.naming.NameParser ;
 import javax.naming.NamingException ;
 
-import org.apache.ldap.common.name.DnParser ;
-import org.apache.ldap.common.name.NameComponentNormalizer ;
-import org.apache.ldap.common.name.SimpleNameComponentNormalizer;
+import org.apache.ldap.common.name.DNParser;
+import org.apache.ldap.common.name.DnOidContainer;
+import org.apache.ldap.common.name.LdapRDN;
 
 
 /**
@@ -32,54 +33,15 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DnNormalizer implements Normalizer
+public class DNNormalizer
 {
-    /** name parser used by this normalizer */
-    private NameParser parser = null ;
-
-
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R S
-    // ------------------------------------------------------------------------
-    
-
-    /**
-     * Creates a Dn Normalizer which normalizes distinguished names by
-     * performing a deep trim to lower case normalization on assertion values
-     * regardless of the attributeType of the name component.
-     */
-    public DnNormalizer() throws NamingException
-    {
-        this ( new SimpleNameComponentNormalizer( new DeepTrimToLowerNormalizer() ) ) ;
-    }
-
-
-    /**
-     * Creates a Dn Normalizer which normalizes distinguished names by
-     * using the same Normalizer to to normalize assertion values regardless
-     * of the attributeType of the name component.
-     *
-     * @param normalizer Normalizer to use for values regardless of attributeType
-     */
-    public DnNormalizer( Normalizer normalizer ) throws NamingException
-    {
-        this ( new SimpleNameComponentNormalizer( normalizer ) ) ;
-    }
-
-
-    /**
-     * Creates a Dn Normalizer which uses a name component normalizer to
-     * dynamically normalize all name component assertion values based on
-     * attributeType.
-     *
-     * @param normalizer the name component normalizer to use
-     */
-    public DnNormalizer( NameComponentNormalizer normalizer ) throws NamingException
-    {
-        parser = new DnParser( normalizer ) ;
-    }
-
-
+	private static DnOidContainer oidContainer;
+	
+	public static void setOidContainer( DnOidContainer oidContainer )
+	{
+		DNNormalizer.oidContainer = oidContainer;
+	}
+	
     /**
      * Normalizes the value if it is a Name or a String returning the String 
      * representation always.  If the value is not a String or a Name the object
@@ -87,24 +49,47 @@
      *
      * @see org.apache.ldap.common.schema.Normalizer#normalize(java.lang.Object)
      */
-    public Object normalize( Object value ) throws NamingException
+    public static Object normalize( Object value ) throws NamingException
     {
         if ( value == null )
         {
             return null;
         }
         
-        String str = null ;
+        Name name = null;
 
         if ( value instanceof Name )
         {
-            str = value.toString() ;
+            name = (Name)value;
         }
         else if ( value instanceof String )
         {
-            str = ( String ) value ;
+            name = DNParser.getNameParser().parse( ( String ) value ) ;
         }
 
-        return parser.parse( str ).toString() ;
+        // Loop on every NameComponent
+        
+        if ( name.size() != 0 )
+        {
+        	Enumeration rdns = name.getAll();
+        	
+        	while ( rdns.hasMoreElements() )
+        	{
+        		// loop on all AttributeTypeAndValue
+        		
+        		LdapRDN rdn = (LdapRDN)rdns.nextElement();
+        		
+        		if ( rdn.getNbAtavs() > 1 )
+        		{
+        			
+        		}
+        		else
+        		{
+        			
+        		}
+        	}
+        }
+        
+        return name;
     }
 }



Mime
View raw message