Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 23304 invoked from network); 19 Dec 2005 00:02:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Dec 2005 00:02:55 -0000 Received: (qmail 24954 invoked by uid 500); 19 Dec 2005 00:02:53 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 24571 invoked by uid 500); 19 Dec 2005 00:02:51 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 24401 invoked by uid 99); 19 Dec 2005 00:02:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2005 16:02:48 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 18 Dec 2005 16:01:38 -0800 Received: (qmail 22722 invoked by uid 65534); 19 Dec 2005 00:01:18 -0000 Message-ID: <20051219000118.22721.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r357577 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java Date: Mon, 19 Dec 2005 00:01:18 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Sun Dec 18 16:01:13 2005 New Revision: 357577 URL: http://svn.apache.org/viewcvs?rev=357577&view=rev Log: - Replaced LdapName by LdapDN - Deleted a commemnted method - Cleaned the imports Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java?rev=357577&r1=357576&r2=357577&view=diff ============================================================================== --- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java (original) +++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/util/NamespaceTools.java Sun Dec 18 16:01:13 2005 @@ -26,11 +26,15 @@ package org.apache.ldap.common.util ; -import org.apache.ldap.common.name.LdapName; +import org.apache.ldap.common.name.LdapDN; -import javax.naming.*; import java.util.ArrayList; +import javax.naming.CompositeName; +import javax.naming.InvalidNameException; +import javax.naming.Name; +import javax.naming.NamingException; + /** * Tools dealing with common Naming operations. @@ -104,109 +108,6 @@ /** - * Parses an LDAP relative distinguished name to create a Name instance. - * - * @param a_rdn string representing the LDAP relative distinguished name. - * @return the parsed Name of a_rdn. - * @throws InvalidNameException if a_dn is not a valid name, - * or if the dn violates the syntax rules of this name - * - public static Name parse(String a_rdn) - throws InvalidNameException - { - ArrayList l_list ; - - if (a_rdn == null || a_rdn.equals("")) { - return new LdapName(new ArrayList()) ; - } else if (a_rdn.indexOf(',') == -1) { - if (a_rdn.indexOf('=') == -1) { - throw new InvalidNameException(a_rdn + - " is not a valid distinguished name component.") ; - } - - l_list = new ArrayList() ; - l_list.add(a_rdn) ; - return new LdapName(l_list) ; - } - - l_list = new ArrayList() ; - String l_rest = a_rdn ; - String l_token = null ; - int l_index = -1 ; - - while ((l_index = l_rest.indexOf(',')) != -1) { - l_token = l_rest.substring(0, l_index) ; - l_rest = l_rest.substring(l_index + 1) ; - - if (l_token.indexOf('=') == -1) { - throw new InvalidNameException(a_rdn - + " is not a valid relative DN component.") ; - } - - l_list.add(l_token) ; - } - - if (l_rest.indexOf('=') == -1) { - throw new InvalidNameException(l_rest - + " is not a valid relative DN component.") ; - } - - l_list.add(l_rest) ; - - return new LdapName(l_list) ; - } - */ - - - /** - * Gets a DN parser. - * - * @return the distinguished name parser. - * - public static NameParser getNameParser() - { - return new NameParser() { - public Name parse(String a_rdn) - throws InvalidNameException - { - return NamespaceTools.parse(a_rdn) ; - } - } ; - } - */ - - - /** - * @task What is this method for??? It does not make sense out of a Context - * implementation. - * - * @param a_name the potentially federated name to get this namespaces - * component from. - * @return this namespaces name component. - * @throws InvalidNameException when a_name is a CompositeName greater than - * size 1. - * - public static Name getNamespaceName(Name a_name) - throws InvalidNameException - { - if (a_name instanceof CompositeName) { - // We do not federate! - if (a_name.size() > 1) { - throw new InvalidNameException(a_name.toString() + - " has more components than namespace can handle") ; - } - - // Turn component that belongs to you into a compound name - return parse(a_name.get(0)); - } else { - // Already parsed - return a_name ; - } - } - */ - - - /** * Generates the string representation of a name. * * @task what the hell are these functions for if toString on a Name returns @@ -421,13 +322,13 @@ */ public static Name getRelativeName( Name ancestor, Name descendant ) throws NamingException { - LdapName rdn = new LdapName( descendant.toString() ); + LdapDN dn = (LdapDN)descendant; - if ( rdn.startsWith( ancestor ) ) + if ( dn.startsWith( ancestor ) ) { - for ( int ii = 0; ii < ancestor.size(); ii++ ) + for ( int i = 0; i < ancestor.size(); i++ ) { - rdn.remove( 0 ); + dn.remove( 0 ); } } else @@ -437,7 +338,7 @@ throw e; } - return rdn; + return dn; }