directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r357575 - /directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java
Date Sun, 18 Dec 2005 23:59:44 GMT
Author: elecharny
Date: Sun Dec 18 15:59:40 2005
New Revision: 357575

URL: http://svn.apache.org/viewcvs?rev=357575&view=rev
Log:
- Added an iterator() method 
- Added a method that return a single atav

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

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java?rev=357575&r1=357574&r2=357575&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java
(original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java
Sun Dec 18 15:59:40 2005
@@ -502,6 +502,46 @@
     }
     
     /**
+     * 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, each a string
+     */
+    public Iterator iterator()
+    {
+        if ( nbAtavs == 1 )
+        {
+            return new Iterator() 
+            {
+                private boolean hasMoreElement = true;
+
+                public boolean hasNext()
+                {
+                    return hasMoreElement ;
+                }
+
+                public Object next()
+                {
+                	Object obj = atav ;
+                	hasMoreElement = false ;
+                	return obj ;
+                }
+                
+                public void remove()
+                {
+                	
+                }
+            };
+        }
+        else
+        {
+        	return atavs.values().iterator();
+        }
+    }
+    
+    /**
      * Clone the LdapRDN
      */
     public Object clone()
@@ -656,5 +696,25 @@
     public int getNbAtavs()
     {
         return nbAtavs;
+    }
+    
+    /**
+     * Return the unique AttributeTypeAndValue, or the first one of we have more than one
+     * @return The first AttributeTypeAndValue of this RDN
+     */
+    public AttributeTypeAndValue getAtav()
+    {
+    	if ( nbAtavs == 0 )
+    	{
+    		return null;
+    	}
+    	else if ( nbAtavs == 1 )
+    	{
+    		return atav;
+    	}
+    	else
+    	{
+    		return (AttributeTypeAndValue)atavs.get( lowest ); 
+    	}
     }
 }



Mime
View raw message