directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r357569 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java
Date Sun, 18 Dec 2005 23:55:29 GMT
Author: elecharny
Date: Sun Dec 18 15:55:25 2005
New Revision: 357569

URL: http://svn.apache.org/viewcvs?rev=357569&view=rev
Log:
Create a singleton to return a valid instance of the DNParser.

Modified:
    directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java?rev=357569&r1=357568&r2=357569&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/DNParser.java
Sun Dec 18 15:55:25 2005
@@ -58,7 +58,33 @@
  */
 public class DNParser implements NameParser
 {
-    public static void parse( String dn, List rdns ) throws InvalidNameException
+	private static DNParser instance = new DNParser();
+	
+	/**
+	 * A private constructor. It's useless, as this object is totally stateless,
+	 * but we need to expose a NameParser.
+	 *
+	 */
+	private DNParser()
+	{
+	}
+	
+	/**
+	 * Get a reference to the NameParser. Needed to be compliant with the JNDI API
+	 * @return An instance of the NameParser
+	 */
+	public static NameParser getNameParser()
+	{
+		return instance;
+	}
+	
+	/** 
+	 * Parse a DN 
+	 * @param dn The DN to be parsed
+	 * @param rdns The list that will contain the RDNs
+	 * @throws InvalidNameException If the DN is invalid
+	 */
+    public static void parseInternal( String dn, List rdns ) throws InvalidNameException
     {
         // We won't decode the LdapDN using the bytes.
         char[] chars = dn.trim().toCharArray();
@@ -101,11 +127,6 @@
         }
     }
     
-    private static Name internalParse( String dn ) throws InvalidNameException
-    {
-        return new LdapDN( dn );
-    }
-
     /**
      * Parse a String and return a LdapDN if the String is a valid DN
      * @param dn The DN to parse
@@ -114,6 +135,6 @@
      */
     public Name parse( String dn ) throws InvalidNameException
     {
-        return DNParser.internalParse( dn );
+        return new LdapDN( dn );
     }
 }



Mime
View raw message