Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 21570 invoked from network); 19 Dec 2005 00:00:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Dec 2005 00:00:07 -0000 Received: (qmail 23410 invoked by uid 500); 19 Dec 2005 00:00:06 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 23385 invoked by uid 500); 19 Dec 2005 00:00:06 -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 23374 invoked by uid 99); 19 Dec 2005 00:00:06 -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:00:06 -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:00:05 -0800 Received: (qmail 21386 invoked by uid 65534); 18 Dec 2005 23:59:45 -0000 Message-ID: <20051218235945.21385.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -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 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 ); + } } }