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 2007/01/15 16:30:05 UTC

svn commit: r496372 - /directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java

Author: elecharny
Date: Mon Jan 15 07:30:05 2007
New Revision: 496372

URL: http://svn.apache.org/viewvc?view=rev&rev=496372
Log:
Added a method to handle correctly the attribute ID

Modified:
    directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java?view=diff&rev=496372&r1=496371&r2=496372
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java Mon Jan 15 07:30:05 2007
@@ -367,16 +367,7 @@
     {
     	if ( attrId != null )
     	{
-            String key = null;
-            
-            if ( "+".equals( attrId ) || "*".equals( attrId ) ) 
-            {
-                key = attrId;
-            }
-            else
-            {
-                key = StringTools.toLowerCase( attrId );
-            }
+            String key = idToLowerCase( attrId );
             
     		Holder holder = (Holder)keyMap.get( key );
     		return holder != null ? holder.attribute : null;
@@ -449,7 +440,8 @@
         Attribute attr = new AttributeImpl( attrId );
         attr.add( val );
         
-        String key = StringTools.toLowerCase( attrId );
+        String key = idToLowerCase( attrId );
+        
         keyMap.put( key, new Holder( attrId, attr) );
         return attr;
     }
@@ -471,16 +463,7 @@
     public Attribute put( Attribute attr )
     {
         String id = attr.getID();
-        String key = null;
-        
-        if ( "+".equals( id ) || "*".equals(  id  ) )
-        {
-            key = id;
-        }
-        else
-        {
-            key = StringTools.toLowerCase( attr.getID() );
-        }
+        String key = idToLowerCase( id );
         
         Attribute old = null;
         Attribute newAttr = attr;
@@ -500,7 +483,7 @@
         }
         else if ( attr instanceof BasicAttribute )
         {
-            newAttr = new AttributeImpl( attr.getID() );
+            newAttr = new AttributeImpl( id );
         	 
         	try
         	{
@@ -517,7 +500,7 @@
         	}
         }
         
-        keyMap.put( key, new Holder( attr.getID(), newAttr ) );
+        keyMap.put( key, new Holder( id, newAttr ) );
         return old;
     }
 
@@ -535,7 +518,7 @@
      */
     public Attribute remove( String attrId )
     {
-    	String key = StringTools.toLowerCase( attrId );
+    	String key = idToLowerCase( attrId );
     	
         if ( keyMap.containsKey( key ) )
         {
@@ -556,6 +539,25 @@
         }
     }
 
+    /**
+     * Private method to allow '*' and '+' attribute ID to be 
+     * accepted as a key.
+     */
+    private String idToLowerCase( String id )
+    {
+        String key = null;
+        
+        if ( "+".equals( id ) || "*".equals(  id  ) )
+        {
+            key = id;
+        }
+        else
+        {
+            key = StringTools.toLowerCase( id );
+        }
+
+        return key;
+    }
 
     /**
      * Makes a shallow copy of the attribute set. The new set contains the same