You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/12/20 00:57:09 UTC
svn commit: r357844 -
/directory/shared/ldap/branches/DN-refactoring/common/src/main/java/org/apache/ldap/common/name/LdapRDN.java
Author: elecharny
Date: Mon Dec 19 15:56:56 2005
New Revision: 357844
URL: http://svn.apache.org/viewcvs?rev=357844&view=rev
Log:
- Fixed the compareTo() metod
- Fixed the initialization
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=357844&r1=357843&r2=357844&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 Mon Dec 19 15:56:56 2005
@@ -98,7 +98,7 @@
private MultiHashMap atavs;
/** Stores the lowest element of the RDN */
- private transient String lowest = null;
+ private transient String lowest;
/**
* A simple AttributeTypeAndValue is used to store the LdapRDN for the simple
@@ -196,8 +196,7 @@
// Don't waste space... This is not so often we have multiple
// name-components in a RDN... So we won't initialize the Map.
atavs = null;
- atav = new AttributeTypeAndValue( type, value );
- nbAtavs = 1;
+ addAttributeTypeAndValue( type, value );
normalize();
upName = type + '=' + value;
}
@@ -578,7 +577,11 @@
* Compares two RDN. They are equals if :
* - their have the same number of NC (AttributeTypeAndValue)
* - for each NC in object, their is one NC which is equal
- * - comparizon are done case insensitive
+ * - comparizon of type are done case insensitive
+ * - each value is equel, case sensitive
+ *
+ * If the RDNs are not equals, a positive number is returned if the
+ * first RDN is greated, negative otherwise
* @param object
* @return
*/
@@ -588,9 +591,14 @@
{
LdapRDN rdn = (LdapRDN)object;
- if ( ( rdn == null ) || ( rdn.nbAtavs != nbAtavs ) )
+ if ( rdn == null )
+ {
+ return 1;
+ }
+
+ if ( rdn.nbAtavs != nbAtavs )
{
- return NOT_EQUALS;
+ return nbAtavs - rdn.nbAtavs;
}
switch ( nbAtavs )
@@ -626,6 +634,7 @@
Iterator atavIter1 = atavList.iterator();
Set atavSet = new HashSet();
+ // We build a set of value from the local RDN
while ( atavIter1.hasNext() )
{
AttributeTypeAndValue atavValue = (AttributeTypeAndValue)atavIter1.next();
@@ -634,6 +643,7 @@
Iterator atavIter2 = atavList2.iterator();
+ // Now, we compare each NC from the second RDN to the NC of the first RDN
while ( atavIter2.hasNext() )
{
AttributeTypeAndValue atavValue = (AttributeTypeAndValue)atavIter2.next();