directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r537358 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Date Sat, 12 May 2007 08:55:31 GMT
Author: elecharny
Date: Sat May 12 01:55:30 2007
New Revision: 537358

URL: http://svn.apache.org/viewvc?view=rev&rev=537358
Log:
Added a addNormalized(RDN) method to speed up the add(RDN) method,
when the RDN is already normalized.

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?view=diff&rev=537358&r1=537357&r2=537358
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Sat May 12 01:55:30 2007
@@ -1096,8 +1096,43 @@
     public Name add( Rdn newRdn )
     {
         rdns.add( 0, newRdn );
+        
         normalizeInternal();
         toUpName();
+
+        return this;
+    }
+
+    /**
+     * Adds a single normalized RDN to the end of this name.
+     *
+     * @param newRdn
+     *            the RDN to add
+     * @return the updated name (not a new one)
+     * @throws InvalidNameException
+     *             if adding <tt>RDN</tt> would violate the syntax rules of
+     *             this name
+     */
+    public Name addNormalized( Rdn newRdn )
+    {
+        rdns.add( 0, newRdn );
+        
+        // Avoid a call to the toNormName() method which
+        // will iterate through all the rdns, when we only
+        // have to build a new normName by using the current
+        // RDN normalized name. The very same for upName.
+        if (rdns.size() == 1 )
+        {
+        	normName = newRdn.toString();
+        	upName = newRdn.getUpName();
+        }
+        else
+        {
+        	normName = newRdn + "," + normName;
+        	upName = newRdn.getUpName() + "," + upName;
+        }
+        
+        bytes = StringTools.getBytesUtf8( normName );
 
         return this;
     }



Mime
View raw message