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 2005/09/27 15:59:16 UTC
svn commit: r291943 -
/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
Author: elecharny
Date: Tue Sep 27 06:59:11 2005
New Revision: 291943
URL: http://svn.apache.org/viewcvs?rev=291943&view=rev
Log:
Committed to be able to work at home
Modified:
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java?rev=291943&r1=291942&r2=291943&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java Tue Sep 27 06:59:11 2005
@@ -21,9 +21,7 @@
import java.util.Iterator;
import javax.naming.InvalidNameException;
-import javax.naming.Name;
-import org.apache.asn1.codec.DecoderException;
import org.apache.asn1new.ldap.codec.utils.DNUtils;
import org.apache.asn1new.util.StringUtils;
@@ -90,63 +88,11 @@
* @param bytes The byte buffer that contains the DN
* @exception A InvalidNameException is thrown if the buffer does not contains a valid DN.
*/
- public LdapDN( String string ) throws InvalidNameException
+ public LdapDN( String string ) throws InvalidNameException, UnsupportedEncodingException
{
- this( string.toCharArray() );
+ this( string.getBytes( "UTF-8" ) );
name = string;
- nameNormalized = normalize();
- }
-
- /**
- * Parse a buffer and checks that it is a valid DN <br>
- * <p>
- * <distinguishedName> ::= <name> | e <br>
- * <name> ::= <name-component> <name-components> <br>
- * <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e <br>
- * </p>
- *
- * @param bytes The byte buffer that contains the DN
- * @exception A InvalidNameException is thrown if the buffer does not contains a valid DN.
- */
- public LdapDN( char[] chars ) throws InvalidNameException
- {
- if ( ( chars == null ) || ( chars.length == 0 ) )
- {
- return;
- }
-
- int pos = 0;
- LdapRDN rdn = new LdapRDN();
-
- // <name> ::= <name-component> <name-components>
- // <name-components> ::= <spaces> <separator> <spaces> <name-component> <name-components> | e
- if ( ( pos = LdapRDN.parseNameComponent( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR )
- {
- do
- {
- rdns.add( rdn.clone() );
- rdn.clear();
-
- if ( ( StringUtils.isCharASCII( chars, pos, ',' ) == false ) &&
- ( StringUtils.isCharASCII( chars, pos, ';' ) == false ) )
- {
- break;
- }
-
- chars[pos] = ',';
- pos++;
-
- pos = StringUtils.trimLeft( chars, pos );
- }
- while ( ( pos = LdapRDN.parseNameComponent( chars, pos, rdn ) ) != DNUtils.PARSING_ERROR );
- }
- else
- {
- throw new InvalidNameException( "Bad DN : " + new String( chars ) );
- }
-
- name = new String( chars );
nameNormalized = normalize();
}