directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r412103 - /directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Date Tue, 06 Jun 2006 12:15:18 GMT
Author: elecharny
Date: Tue Jun  6 05:15:18 2006
New Revision: 412103

URL: http://svn.apache.org/viewvc?rev=412103&view=rev
Log:
Fixed the UpName to avoid space trimming.

Modified:
    directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java

Modified: directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?rev=412103&r1=412102&r2=412103&view=diff
==============================================================================
--- directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/branches/shared/optimization/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Tue Jun  6 05:15:18 2006
@@ -115,8 +115,6 @@
      */
     public LdapDN( Name name ) throws InvalidNameException
     {
-        super();
-
         if ( ( name != null ) && ( name.size() != 0 ) )
         {
             for ( int ii = 0; ii < name.size(); ii++ )
@@ -134,10 +132,8 @@
      * 
      * @param list of String name components.
      */
-    LdapDN(List list) throws InvalidNameException
+    LdapDN( List list ) throws InvalidNameException
     {
-        super();
-
         if ( ( list != null ) && ( list.size() != 0 ) )
         {
             Iterator nameComponents = list.iterator();
@@ -157,10 +153,8 @@
      * @param nameComponents
      *            List of String name components.
      */
-    LdapDN(Iterator nameComponents) throws InvalidNameException
+    LdapDN( Iterator nameComponents ) throws InvalidNameException
     {
-        super();
-
         if ( nameComponents != null )
         {
             while ( nameComponents.hasNext() )
@@ -187,7 +181,7 @@
      *                InvalidNameException is thrown if the buffer does not
      *                contains a valid DN.
      */
-    public LdapDN(String upName) throws InvalidNameException
+    public LdapDN( String upName ) throws InvalidNameException
     {
         if ( StringTools.isNotEmpty( upName ) )
         {
@@ -196,7 +190,8 @@
 
         // Stores the representations of a DN : internal (as a string and as a
         // byte[]) and external.
-        normalize( upName );
+        normalize();
+        this.upName = upName;
     }
 
 
@@ -237,10 +232,9 @@
      * 
      * @return a normalized form of the DN
      */
-    private void normalize( String upName )
+    private void normalize()
     {
         normName = toNormName();
-        this.upName = upName == null ? "" : upName;
     }
 
 
@@ -304,7 +298,7 @@
     {
         if ( ( rdns == null ) || ( rdns.size() == 0 ) )
         {
-            return "";
+            upName = "";
         }
         else
         {
@@ -325,8 +319,10 @@
                 sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
             }
 
-            return sb.toString();
+            upName = sb.toString();
         }
+
+        return upName;
     }
 
 
@@ -934,6 +930,8 @@
     public Name addAll( Name suffix ) throws InvalidNameException
     {
         addAll( rdns.size(), suffix );
+        normalize();
+        toUpName();
 
         return this;
     }
@@ -970,7 +968,8 @@
             rdns.addAll( size() - posn, ( ( LdapDN ) name ).rdns );
 
             // Regenerate the normalized name and the original string
-            normalize( toUpName() );
+            normalize();
+            toUpName();
 
             return this;
         }
@@ -998,7 +997,8 @@
         Rdn newRdn = new Rdn( comp );
 
         rdns.add( 0, newRdn );
-        normalize( toUpName() );
+        normalize();
+        toUpName();
 
         return this;
     }
@@ -1016,7 +1016,8 @@
     public Name add( Rdn newRdn ) throws InvalidNameException
     {
         rdns.add( rdns.size() - 1, newRdn );
-        normalize( toUpName() );
+        normalize();
+        toUpName();
 
         return this;
     }
@@ -1053,7 +1054,8 @@
         int realPos = size() - posn;
         rdns.add( realPos, newRdn );
 
-        normalize( toUpName() );
+        normalize();
+        toUpName();
 
         return this;
     }
@@ -1091,7 +1093,8 @@
         int realPos = size() - posn - 1;
         Rdn rdn = ( Rdn ) rdns.remove( realPos );
 
-        normalize( toUpName() );
+        normalize();
+        toUpName();
 
         return rdn;
     }
@@ -1293,17 +1296,14 @@
 
             if ( StringTools.isNotEmpty( StringTools.lowerCase( type ) ) )
             {
-                Normalizer normalizer = ( Normalizer ) oids.get( type );
+                OidNormalizer oidNormalizer = ( OidNormalizer ) oids.get( type );
 
-                if ( normalizer != null )
+                if ( oidNormalizer != null )
                 {
                     Rdn rdnCopy = ( Rdn ) rdn.clone();
                     rdn.clear();
                     
-                    // Should get the OID, not the type
-                    String oid = type;
-
-                    rdn.addAttributeTypeAndValue( oid, (String)normalizer
+                    rdn.addAttributeTypeAndValue( oidNormalizer.getAttributeTypeOid(), (
String ) oidNormalizer.getNormalizer()
                         .normalize( rdnCopy.getValue() ) );
 
                 }
@@ -1363,7 +1363,7 @@
             rdn.setUpName( upName );
         }
 
-        newDn.normalize( newDn.upName );
+        newDn.normalize();
 
         return newDn;
     }



Mime
View raw message