directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r359046 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapDN.java
Date Mon, 26 Dec 2005 10:18:43 GMT
Author: elecharny
Date: Mon Dec 26 02:18:39 2005
New Revision: 359046

URL: http://svn.apache.org/viewcvs?rev=359046&view=rev
Log:
- Added a method getAllRdn() which returns a Rdn enumeration
- Fixed the getAll() method, it now returns a String enumeration

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

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapDN.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapDN.java?rev=359046&r1=359045&r2=359046&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapDN.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapDN.java
Mon Dec 26 02:18:39 2005
@@ -546,7 +546,7 @@
      * this name is undefined.  If the name has zero components,
      * an empty (non-null) enumeration is returned.
      *
-     * @return  an enumeration of the components of this name, each a string
+     * @return  an enumeration of the components of this name, each as string
      */
     public Enumeration getAll()
     {
@@ -575,6 +575,46 @@
 
                 Object obj = rdns.get( rdns.size() - pos - 1 );
                 pos++ ;
+                return obj.toString();
+            }
+        };
+    }
+    
+    /**
+     * Retrieves the components of this name as an enumeration
+     * of strings.  The effect on the enumeration of updates to
+     * this name is undefined.  If the name has zero components,
+     * an empty (non-null) enumeration is returned.
+     *
+     * @return  an enumeration of the components of this name, as Rdn
+     */
+    public Enumeration getAllRdn()
+    {
+        /*
+         * Note that by accessing the name component using the get() method on
+         * the name rather than get() on the list we are reading components from
+         * right to left with increasing index values.  LdapName.get() does the
+         * index translation on m_list for us. 
+         */
+        return new Enumeration() 
+        {
+            private int pos ;
+
+            public boolean hasMoreElements()
+            {
+                return pos < rdns.size() ;
+            }
+
+            public Object nextElement()
+            {
+                if ( pos >= rdns.size() ) 
+                {
+                	log.error( "Exceeded number of elements in the current object" );
+                    throw new NoSuchElementException() ;
+                }
+
+                Object obj = rdns.get( rdns.size() - pos - 1 );
+                pos++ ;
                 return obj ;
             }
         };
@@ -1057,7 +1097,7 @@
     	
     	LdapDN newDn = (LdapDN)dn.clone();
     	
-    	Enumeration rdns = newDn.getAll();
+    	Enumeration rdns = newDn.getAllRdn();
     	
     	// Loop on all RDNs
     	while ( rdns.hasMoreElements() )



Mime
View raw message