directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r496372 - /directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java
Date Mon, 15 Jan 2007 15:30:05 GMT
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



Mime
View raw message