directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r531299 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Date Sun, 22 Apr 2007 22:58:33 GMT
Author: elecharny
Date: Sun Apr 22 15:58:33 2007
New Revision: 531299

URL: http://svn.apache.org/viewvc?view=rev&rev=531299
Log:
Ficed the getAttribute() method : if the attributeType is an OID, then the method will just
return null.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?view=diff&rev=531299&r1=531298&r2=531299
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Sun Apr 22 15:58:33 2007
@@ -218,24 +218,33 @@
      */
     public final static Attribute getAttribute( Attributes attrs, AttributeType type )
     {
-        // optimization bypass to avoid cost of the loop below
-        if ( type.getNames().length == 1 )
+        // check if the attribute's OID is used
+        Attribute attr = attrs.get( type.getOid() );
+        
+        if ( attr != null )
         {
-            return attrs.get( type.getNames()[0] );
+            return attr;
         }
-        
-        // check if the attribute's OID is used
-        if ( attrs.get( type.getOid() ) != null )
+
+        // optimization bypass to avoid cost of the loop below
+        if ( type.getNames().length == 1 )
         {
-            return attrs.get( type.getOid() );
+            attr = attrs.get( type.getNames()[0] );
+            
+            if ( attr != null )
+            {
+                return attr;
+            }
         }
         
         // iterate through aliases
-        for ( int ii = 0; ii < type.getNames().length; ii++ )
+        for ( String alias:type.getNames() )
         {
-            if ( attrs.get( type.getNames()[ii] ) != null )
+            attr = attrs.get( alias );
+            
+            if ( attr != null )
             {
-                return attrs.get( type.getNames()[ii] );
+                return attr;
             }
         }
         



Mime
View raw message