You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/07/31 21:23:15 UTC
svn commit: r427218 -
/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
Author: elecharny
Date: Mon Jul 31 12:23:14 2006
New Revision: 427218
URL: http://svn.apache.org/viewvc?rev=427218&view=rev
Log:
Upgraded the file instead of merging
Modified:
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java?rev=427218&r1=427217&r2=427218&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java Mon Jul 31 12:23:14 2006
@@ -23,6 +23,7 @@
import javax.naming.Name;
import org.apache.directory.shared.ldap.util.DNUtils;
+import org.apache.directory.shared.ldap.util.Position;
import org.apache.directory.shared.ldap.util.StringTools;
import javax.naming.NameParser;
@@ -100,52 +101,48 @@
*/
public static void parseInternal( String dn, List rdns ) throws InvalidNameException
{
- // We won't decode the LdapDN using the bytes.
- char[] chars = dn.trim().toCharArray();
-
- if ( chars.length == 0 )
+ if ( dn.length() == 0 )
{
// We have an empty DN, just get out of the function.
return;
}
- int pos = 0;
+ Position pos = new Position();
+ pos.start = 0;
Rdn rdn = new Rdn();
// <name> ::= <name-component> <name-components>
// <name-components> ::= <spaces> <separator> <spaces> <name-component>
// <name-components> | e
- if ( ( pos = RdnParser.parse( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR )
+ if ( RdnParser.parse( dn, pos, rdn ) != DNUtils.PARSING_ERROR )
{
+ // Now, parse the following nameComponents
do
{
- rdns.add( rdn.clone() );
- rdn.clear();
-
- if ( ( StringTools.isCharASCII( chars, pos, ',' ) == false )
- && ( StringTools.isCharASCII( chars, pos, ';' ) == false ) )
+ rdns.add( rdn );
+ rdn = new Rdn();
+
+ if ( ( StringTools.isCharASCII( dn, pos.start, ',' ) == false )
+ && ( StringTools.isCharASCII( dn, pos.start, ';' ) == false ) )
{
- if ( pos != chars.length )
+ if ( pos.start != dn.length() )
{
- throw new InvalidNameException( "Bad DN : " + new String( chars ) );
+ throw new InvalidNameException( "Bad DN : " + dn );
}
else
{
break;
}
}
-
- chars[pos] = ',';
- pos++;
-
- // pos = StringUtils.trimLeft( chars, pos );
+
+ pos.start++;
}
- while ( ( pos = RdnParser.parse( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR );
+ while ( RdnParser.parse( dn, pos, rdn ) != DNUtils.PARSING_ERROR );
}
else
{
- throw new InvalidNameException( "Bad DN : " + new String( chars ) );
+ throw new InvalidNameException( "Bad DN : " + dn );
}
}