directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r764221 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
Date Sat, 11 Apr 2009 17:24:45 GMT
Author: seelmann
Date: Sat Apr 11 17:24:45 2009
New Revision: 764221

URL: http://svn.apache.org/viewvc?rev=764221&view=rev
Log:
Some improvements

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java?rev=764221&r1=764220&r2=764221&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/FastLdapDnParser.java
Sat Apr 11 17:24:45 2009
@@ -20,12 +20,15 @@
 package org.apache.directory.shared.ldap.name;
 
 
+import java.util.List;
+
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
 import javax.naming.NameParser;
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.util.Position;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -71,6 +74,13 @@
      */
     public void parseDn( String name, LdapDN dn ) throws InvalidNameException
     {
+        parseDn(name, dn.rdns);
+        dn.setUpName( name );
+        dn.normalizeInternal();
+    }
+    
+    void parseDn( String name, List<Rdn> rdns ) throws InvalidNameException
+    {
         if ( name == null || name.trim().length() == 0 )
         {
             // We have an empty DN, just get out of the function.
@@ -85,7 +95,7 @@
         {
             Rdn rdn = new Rdn();
             parseRdnInternal( name, pos, rdn );
-            dn.rdns.add( rdn );
+            rdns.add( rdn );
 
             if ( !hasMoreChars( pos ) )
             {
@@ -105,9 +115,6 @@
                         + ". Excpected ',' or ';'." );
             }
         }
-
-        dn.setUpName( name );
-        dn.normalizeInternal();
     }
 
 
@@ -141,7 +148,7 @@
 
     private void parseRdnInternal( String name, Position pos, Rdn rdn ) throws InvalidNameException
     {
-        int start = pos.start;
+        int rdnStart = pos.start;
 
         // SPACE*
         matchSpaces( name, pos );
@@ -160,13 +167,13 @@
 
         // here we only match "simple" values
         // stops at \ + # " -> Too Complex Exception
-        String value = matchValue( name, pos );
-        String upValue = name.substring( start, pos.start );
+        String upValue = matchValue( name, pos );
+        String value = StringTools.trimRight( upValue );
         // TODO: trim, normalize, etc
 
         rdn.addAttributeTypeAndValue( type, type, upValue, value );
 
-        rdn.setUpName( name.substring( start, pos.start ) );
+        rdn.setUpName( name.substring( rdnStart, pos.start ) );
         rdn.normalize();
 
     }
@@ -182,7 +189,7 @@
     private void matchSpaces( String name, Position pos ) throws InvalidNameException
     {
         char c = ' ';
-        while ( c == ' ' )
+        while ( c == ' ' && hasMoreChars( pos ) )
         {
             c = nextChar( name, pos, true );
         }



Mime
View raw message