directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r494173 [1/2] - in /directory/trunks/shared/ldap: ./ src/main/antlr/ src/main/java/org/apache/directory/shared/ldap/aci/ src/main/java/org/apache/directory/shared/ldap/codec/ src/main/java/org/apache/directory/shared/ldap/codec/add/ src/mai...
Date Mon, 08 Jan 2007 19:42:37 GMT
Author: elecharny
Date: Mon Jan  8 11:42:35 2007
New Revision: 494173

URL: http://svn.apache.org/viewvc?view=rev&rev=494173
Log:
Patch for DIRSERVER-783.
- No more BasicAttribute and BasicAttributes. Use AttributeImpl and AttributesImpl now.
- No more ModificationItem. use ModificationItemImpl now
- lot of refactoring of imports : no more import xxx.*;

Added:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributeImpl.java
      - copied, changed from r494042, directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java
      - copied, changed from r494042, directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/AttributeImplTest.java
      - copied, changed from r494042, directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributeImplTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/AttributesImplTest.java
      - copied, changed from r494042, directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
Removed:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributeImplTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/LockableAttributesImplTest.java
Modified:
    directory/trunks/shared/ldap/   (props changed)
    directory/trunks/shared/ldap/src/main/antlr/ACIItem.g
    directory/trunks/shared/ldap/src/main/antlr/ACIItemChecker.g
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParserImpl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumeration.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/IteratorNamingEnumeration.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequest.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequestImpl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/sp/JavaStoredProcedureUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SequencedHashMap.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/add/AddRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequestTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntryTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/ModifyRequestImplTest.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/message/SearchResponseEntryImplTest.java

Propchange: directory/trunks/shared/ldap/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan  8 11:42:35 2007
@@ -10,5 +10,5 @@
 .project
 .classpath
 *~
-
+.fbprefs
 nbproject

Modified: directory/trunks/shared/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/antlr/ACIItem.g?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/ACIItem.g Mon Jan  8 11:42:35 2007
@@ -32,7 +32,6 @@
 import java.util.Enumeration;
 
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.filter.AssertionEnum;
@@ -41,6 +40,7 @@
 import org.apache.directory.shared.ldap.filter.FilterParserImpl;
 import org.apache.directory.shared.ldap.filter.LeafNode;
 import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationModifier;
@@ -500,7 +500,7 @@
             attributeTypeAndValue = ( String ) attributeTypeAndValueSet.nextElement();
             attributeType = NamespaceTools.getRdnAttribute( attributeTypeAndValue );
             attributeValue = NamespaceTools.getRdnValue( attributeTypeAndValue );
-            attributeSet.add( new BasicAttribute( attributeType, attributeValue ) );
+            attributeSet.add( new AttributeImpl( attributeType, attributeValue ) );
             log.debug( "An attributeTypeAndValue from the set: " + attributeType + "=" +  attributeValue);
         }
         m_protectedItemsMap.put( "attributeValue", new ProtectedItem.AttributeValue( attributeSet ) );

Modified: directory/trunks/shared/ldap/src/main/antlr/ACIItemChecker.g
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/antlr/ACIItemChecker.g?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/ACIItemChecker.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/ACIItemChecker.g Mon Jan  8 11:42:35 2007
@@ -32,7 +32,7 @@
 import java.util.Enumeration;
 
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.filter.AssertionEnum;

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java Mon Jan  8 11:42:35 2007
@@ -492,7 +492,7 @@
                 }
                 catch ( NamingException e )
                 {
-                    // doesn't occur here, it is a BasicAttribute
+                    // doesn't occur here, it is an Attribute
                 }
                 
                 if(it.hasNext()) {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Mon Jan  8 11:42:35 2007
@@ -27,8 +27,6 @@
 
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.shared.asn1.Asn1Object;
 import org.apache.directory.shared.asn1.codec.DecoderException;
@@ -79,6 +77,7 @@
 import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.message.AddResponseImpl;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.message.CompareRequestImpl;
@@ -91,6 +90,7 @@
 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.LdapResultImpl;
 import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
@@ -369,7 +369,7 @@
             // Loop through the modifications
             while ( modifications.hasNext() )
             {
-                snickersMessage.addModification( ( ModificationItem ) modifications.next() );
+                snickersMessage.addModification( ( ModificationItemImpl ) modifications.next() );
             }
         }
 
@@ -640,7 +640,7 @@
             {
                 while ( attributes.hasMoreElements() )
                 {
-                    Attribute attribute = ( BasicAttribute ) attributes.nextElement();
+                    Attribute attribute = ( AttributeImpl ) attributes.nextElement();
 
                     if ( attribute != null )
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Mon Jan  8 11:42:35 2007
@@ -26,6 +26,8 @@
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -42,8 +44,6 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 
 
 /**
@@ -127,7 +127,7 @@
      */
     public void initAttributes()
     {
-        attributes = new BasicAttributes( true );
+        attributes = new AttributesImpl( true );
     }
 
 
@@ -155,8 +155,8 @@
             return;
         }
         
-        // fix this to use LockableAttributeImpl(type.getString().toLowerCase())
-        currentAttribute = new BasicAttribute( type.toLowerCase() );
+        // fix this to use AttributeImpl(type.getString().toLowerCase())
+        currentAttribute = new AttributeImpl( type.toLowerCase() );
         attributes.put( currentAttribute );
     }
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java Mon Jan  8 11:42:35 2007
@@ -26,6 +26,8 @@
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -41,9 +43,7 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 
 
 /**
@@ -86,8 +86,8 @@
     /** The DN to be modified. */
     private LdapDN object;
 
-    /** The modifications list. This is an array of ModificationItem. */
-    private List<ModificationItem> modifications;
+    /** The modifications list. This is an array of ModificationItemImpl. */
+    private List<ModificationItemImpl> modifications;
 
     /** The current attribute being decoded */
     private Attribute currentAttribute;
@@ -142,7 +142,7 @@
      */
     public void initModifications()
     {
-        modifications = new ArrayList<ModificationItem>();
+        modifications = new ArrayList<ModificationItemImpl>();
     }
 
 
@@ -151,7 +151,7 @@
      * 
      * @return Returns the modifications.
      */
-    public List<ModificationItem> getModifications()
+    public List<ModificationItemImpl> getModifications()
     {
         return modifications;
     }
@@ -168,7 +168,7 @@
 
         if ( currentAttribute == null )
         {
-            modifications = new ArrayList<ModificationItem>();
+            modifications = new ArrayList<ModificationItemImpl>();
         }
     }
 
@@ -180,7 +180,7 @@
      */
     public void addAttributeTypeAndValues( String type )
     {
-        currentAttribute = new BasicAttribute( StringTools.lowerCase( type ) );
+        currentAttribute = new AttributeImpl( StringTools.lowerCase( type ) );
 
         int operation = 0;
 
@@ -200,7 +200,7 @@
                 break;
         }
 
-        ModificationItem modification = new ModificationItem( operation, currentAttribute );
+        ModificationItemImpl modification = new ModificationItemImpl( operation, currentAttribute );
         modifications.add( modification );
     }
 
@@ -330,7 +330,7 @@
                 int localModificationSequenceLength = 1 + 1 + 1;
                 int localValuesLength = 0;
 
-                ModificationItem modification = ( ModificationItem ) modificationsIterator.next();
+                ModificationItemImpl modification = ( ModificationItemImpl ) modificationsIterator.next();
 
                 // Modification length initialized with the type
                 int typeLength = modification.getAttribute().getID().length();
@@ -448,7 +448,7 @@
                 // Compute the modifications length
                 while ( modificationIterator.hasNext() )
                 {
-                    ModificationItem modification = ( ModificationItem ) modificationIterator.next();
+                    ModificationItemImpl modification = ( ModificationItemImpl ) modificationIterator.next();
 
                     // The modification sequence
                     buffer.put( UniversalTag.SEQUENCE_TAG );
@@ -547,7 +547,7 @@
         {
             int i = 0;
             
-            for ( ModificationItem modification:modifications )
+            for ( ModificationItemImpl modification:modifications )
             {
                 sb.append( "            Modification[" ).append( i ).append( "]\n" );
                 sb.append( "                Operation : " );

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchRequest.java Mon Jan  8 11:42:35 2007
@@ -30,6 +30,8 @@
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ScopeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
@@ -40,8 +42,6 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 
 
 /**
@@ -114,7 +114,7 @@
         super();
 
         currentFilter = null;
-        attributes = new BasicAttributes( true );
+        attributes = new AttributesImpl( true );
     }
 
 
@@ -150,8 +150,7 @@
      */
     public void addAttribute( String attribute )
     {
-        //attributes.put( new BasicAttribute( StringTools.lowerCase( attribute ) ) );
-        attributes.put( new BasicAttribute( attribute ) );
+        attributes.put( new AttributeImpl( attribute ) );
     }
 
 
@@ -489,7 +488,7 @@
             // Compute the attributes length
             while ( attributeIterator.hasMoreElements() )
             {
-                Attribute attribute = ( BasicAttribute ) attributeIterator.nextElement();
+                Attribute attribute = ( AttributeImpl ) attributeIterator.nextElement();
 
                 // add the attribute length to the attributes length
                 try
@@ -583,7 +582,7 @@
                 // encode each attribute
                 while ( attributeIterator.hasMoreElements() )
                 {
-                    Attribute attribute = ( BasicAttribute ) attributeIterator.nextElement();
+                    Attribute attribute = ( AttributeImpl ) attributeIterator.nextElement();
 
                     Value.encode( buffer, attribute.getID() );
                 }
@@ -632,7 +631,7 @@
             {
                 while ( attrs.hasMoreElements() )
                 {
-                    Attribute attr = ( BasicAttribute ) attrs.nextElement();
+                    Attribute attr = ( AttributeImpl ) attrs.nextElement();
         
                     if ( isFirst )
                     {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/SearchResultEntry.java Mon Jan  8 11:42:35 2007
@@ -27,6 +27,8 @@
 import org.apache.directory.shared.asn1.util.Asn1StringUtils;
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -40,8 +42,6 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 
 
 /**
@@ -103,7 +103,7 @@
     public SearchResultEntry()
     {
         super();
-        partialAttributeList = new BasicAttributes( true );
+        partialAttributeList = new AttributesImpl( true );
     }
 
 
@@ -170,7 +170,7 @@
      */
     public void addAttributeValues( String type )
     {
-        currentAttributeValue = new BasicAttribute( StringTools.lowerCase( type ) );
+        currentAttributeValue = new AttributeImpl( StringTools.lowerCase( type ) );
 
         partialAttributeList.put( currentAttributeValue );
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParserImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParserImpl.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParserImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParserImpl.java Mon Jan  8 11:42:35 2007
@@ -25,13 +25,16 @@
 import java.io.IOException;
 import java.text.ParseException;
 
-import antlr.*;
-
 import org.apache.directory.shared.ldap.filter.AntlrFilterLexer;
 import org.apache.directory.shared.ldap.filter.AntlrFilterParser;
 import org.apache.directory.shared.ldap.filter.AntlrFilterValueLexer;
 import org.apache.directory.shared.ldap.filter.AntlrFilterValueParser;
 import org.apache.directory.shared.ldap.util.StringTools;
+
+import antlr.LexerSharedInputState;
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
+import antlr.TokenStreamSelector;
 
 
 public class FilterParserImpl implements FilterParser

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java Mon Jan  8 11:42:35 2007
@@ -30,12 +30,12 @@
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.Control;
 
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
@@ -52,9 +52,9 @@
     private int changeType;
 
     /** the modification item list */
-    private List<ModificationItem> modificationList;
+    private List<ModificationItemImpl> modificationList;
 
-    private Map<String, ModificationItem> modificationItems;
+    private Map<String, ModificationItemImpl> modificationItems;
 
     /** the dn of the ldif entry */
     private String dn;
@@ -69,7 +69,7 @@
     private boolean deleteOldRdn;
 
     /** attributes of the entry */
-    private BasicAttributes attributeList;
+    private Attributes attributeList;
 
     /** The possible change types */
     public final static int ADD = 0;
@@ -91,10 +91,10 @@
     public Entry()
     {
         changeType = ADD; // Default LDIF content
-        modificationList = new LinkedList<ModificationItem>();
-        modificationItems = new HashMap<String, ModificationItem>();
+        modificationList = new LinkedList<ModificationItemImpl>();
+        modificationItems = new HashMap<String, ModificationItemImpl>();
         dn = null;
-        attributeList = new BasicAttributes( true );
+        attributeList = new AttributesImpl( true );
         control = null;
     }
 
@@ -156,7 +156,7 @@
      * 
      * @param modification The modification to be added
      */
-    public void addModificationItem( ModificationItem modification )
+    public void addModificationItem( ModificationItemImpl modification )
     {
         if ( changeType == MODIFY )
         {
@@ -181,7 +181,7 @@
         {
             if ( modificationItems.containsKey( attr.getID() ) )
             {
-                ModificationItem item = modificationItems.get( attr.getID() );
+                ModificationItemImpl item = modificationItems.get( attr.getID() );
                 Attribute attribute = item.getAttribute();
 
                 Enumeration attrs = attr.getAll();
@@ -193,7 +193,7 @@
             }
             else
             {
-                ModificationItem item = new ModificationItem( modOp, attr );
+                ModificationItemImpl item = new ModificationItemImpl( modOp, attr );
                 modificationList.add( item );
                 modificationItems.put( attr.getID(), item );
             }
@@ -216,11 +216,11 @@
     {
         if ( changeType == MODIFY )
         {
-            BasicAttribute attr = new BasicAttribute( id, value );
+            Attribute attr = new AttributeImpl( id, value );
 
             if ( modificationItems.containsKey( id ) )
             {
-                ModificationItem item = modificationItems.get( id );
+                ModificationItemImpl item = modificationItems.get( id );
                 
                 if ( item.getModificationOp() != modOp )
                 {
@@ -236,7 +236,7 @@
             }
             else
             {
-                ModificationItem item = new ModificationItem( modOp, attr );
+                ModificationItemImpl item = new ModificationItemImpl( modOp, attr );
                 modificationList.add( item );
                 modificationItems.put( id, item );
             }
@@ -316,7 +316,7 @@
     /**
      * @return The list of modification items
      */
-    public List<ModificationItem> getModificationItems()
+    public List<ModificationItemImpl> getModificationItems()
     {
         return modificationList;
     }
@@ -348,7 +348,7 @@
     {
         if ( "dn".equalsIgnoreCase( attributeId ) )
         {
-            return new BasicAttribute( "dn", dn );
+            return new AttributeImpl( "dn", dn );
         }
 
         return attributeList.get( attributeId );
@@ -501,9 +501,9 @@
 
         if ( modificationList != null )
         {
-            for ( ModificationItem modif:modificationList )
+            for ( ModificationItemImpl modif:modificationList )
             {
-                ModificationItem modifClone = new ModificationItem( modif.getModificationOp(), (Attribute) modif.getAttribute()
+                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), (Attribute) modif.getAttribute()
                         .clone() );
                 clone.modificationList.add( modifClone );
             }
@@ -513,8 +513,8 @@
         {
             for ( String key:modificationItems.keySet() )
             {
-                ModificationItem modif = modificationItems.get( key );
-                ModificationItem modifClone = new ModificationItem( modif.getModificationOp(), (Attribute) modif.getAttribute()
+                ModificationItemImpl modif = modificationItems.get( key );
+                ModificationItemImpl modifClone = new ModificationItemImpl( modif.getModificationOp(), (Attribute) modif.getAttribute()
                         .clone() );
                 clone.modificationItems.put( key, modifClone );
             }
@@ -523,39 +523,7 @@
 
         if ( attributeList != null )
         {
-            try
-            {
-                NamingEnumeration attrs = attributeList.getAll();
-
-                while ( attrs.hasMore() )
-                {
-                    Attribute attribute = (BasicAttribute) attrs.nextElement();
-                    Attribute attrClone = new BasicAttribute( attribute.getID() );
-
-                    for ( NamingEnumeration iter = attribute.getAll(); iter.hasMoreElements(); )
-                    {
-                        Object value = iter.next();
-
-                        if ( value instanceof String )
-                        {
-                            attrClone.add( value );
-                        }
-                        else if ( value instanceof byte[] )
-                        {
-                            int length = ( (byte[]) value ).length;
-                            byte[] valueClone = new byte[length];
-                            System.arraycopy( value, 0, valueClone, 0, length );
-                            attrClone.add( valueClone );
-                        }
-                    }
-
-                    clone.attributeList.put( attrClone );
-                }
-            }
-            catch (NamingException ne)
-            {
-                throw new CloneNotSupportedException( ne.getMessage() );
-            }
+            clone.attributeList = (Attributes)attributeList.clone();
         }
 
         return clone;
@@ -606,7 +574,7 @@
     {
         StringBuffer sb = new StringBuffer();
         
-        for ( ModificationItem modif:modificationList )
+        for ( ModificationItemImpl modif:modificationList )
         {
             sb.append( "            Operation: " );
             

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java Mon Jan  8 11:42:35 2007
@@ -42,12 +42,12 @@
 import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.DirContext;
 import javax.naming.ldap.Control;
 
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.name.LdapDnParser;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.Base64;
@@ -833,7 +833,7 @@
             Object attributeValue = parseSimpleValue( line, colonIndex );
 
             // Create an attribute
-            return new BasicAttribute( attributeType, attributeValue );
+            return new AttributeImpl( attributeType, attributeValue );
         }
         else
         {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessage.java Mon Jan  8 11:42:35 2007
@@ -19,8 +19,11 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
-import java.util.*;
 
 
 /**

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumeration.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumeration.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ArrayNamingEnumeration.java Mon Jan  8 11:42:35 2007
@@ -30,10 +30,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ArrayNamingEnumeration implements NamingEnumeration
+public class ArrayNamingEnumeration<T> implements NamingEnumeration<T>
 {
     /** the objects to enumerate */
-    private final Object[] objects;
+    private final T[] objects;
 
     /** the index pointing into the array */
     private int index = 0;
@@ -45,7 +45,7 @@
      * @param objects
      *            the objects to enumerate over
      */
-    public ArrayNamingEnumeration(Object[] objects)
+    public ArrayNamingEnumeration( T[] objects )
     {
         this.objects = objects;
     }
@@ -71,14 +71,14 @@
     }
 
 
-    public Object next()
+    public T next()
     {
         if ( objects == null || objects.length == 0 || index >= objects.length )
         {
             throw new NoSuchElementException();
         }
 
-        Object retval = objects[index];
+        T retval = objects[index];
         index++;
         return retval;
     }
@@ -90,7 +90,7 @@
     }
 
 
-    public Object nextElement()
+    public T nextElement()
     {
         return next();
     }

Copied: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributeImpl.java (from r494042, directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java)
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributeImpl.java?view=diff&rev=494173&p1=directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java&r1=494042&p2=directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributeImpl.java&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributeImpl.java Mon Jan  8 11:42:35 2007
@@ -21,9 +21,11 @@
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.NoSuchElementException;
+import java.util.Map;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -31,6 +33,7 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.DirContext;
 
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,9 +45,9 @@
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  * @version $Rev$
  */
-public class LockableAttributeImpl implements Attribute
+public class AttributeImpl implements Attribute
 {
-    private static final Logger log = LoggerFactory.getLogger( LockableAttributeImpl.class );
+    private static final Logger log = LoggerFactory.getLogger( AttributeImpl.class );
 
     private static final long serialVersionUID = -5158233254341746514L;
 
@@ -52,88 +55,67 @@
     private final String upId;
 
     /** In case we have only one value, just use this container */
-    Object value;
+    private Object value;
     
-    /** the list of attribute values */
+    /** the list of attribute values, if unordered */
     private List<Object> list;
     
     /** The number of values stored */
-    int size = 0;
-
+    private int size = 0;
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
     /**
-     * Creates a permanently LockableAttribute on id whose locking behavoir is
-     * dicatated by parent.
+     * Creates a permanently Attribute on id whose locking behavior is
+     * dictated by parent.
      * 
      * @param id
      *            the id or name of this attribute.
      */
-    public LockableAttributeImpl(final String id)
+    public AttributeImpl( String id )
     {
         upId = id;
         value = null;
-        list = null; //new ArrayList();
+        list = null;
         size = 0;
     }
 
 
     /**
-     * Creates a permanently LockableAttribute on id with a single value.
+     * Creates a permanently Attribute on id with a single value.
      * 
      * @param id
      *            the id or name of this attribute.
      * @param value
      *            a value for the attribute
      */
-    public LockableAttributeImpl(final String id, final Object value)
+    public AttributeImpl( String id, Object value )
     {
         upId = id;
-        list = null; // new ArrayList();
-        this.value = value; //list.add( value );
+        list = null;
+        this.value = AttributeUtils.cloneValue( value );
         size = 1;
     }
 
 
     /**
-     * Creates a permanently LockableAttribute on id with a single value.
+     * Creates a permanently Attribute on id with a single value.
      * 
      * @param id
      *            the id or name of this attribute.
      * @param value
      *            a value for the attribute
      */
-    public LockableAttributeImpl(final String id, final byte[] value)
+    public AttributeImpl( String id, byte[] value )
     {
         upId = id;
-        list = null; //new ArrayList();
-        this.value = value;
-        //list.add( value );
+        list = null;
+        this.value = AttributeUtils.cloneValue( value );
         size = 1;
     }
 
-
-    /**
-     * Creates a permanently LockableAttribute on id whose locking behavoir is
-     * dicatated by parent. Used for the clone method.
-     * 
-     * @param id
-     *            the id or name of this attribute
-     * @param list
-     *            the list of values to start with
-     */
-    private LockableAttributeImpl(final String id, final List<Object> list)
-    {
-        upId = id;
-        this.list = list;
-        value = null;
-        size = (list != null ? list.size() : 0);
-    }
-
-
     // ------------------------------------------------------------------------
     // javax.naming.directory.Attribute Interface Method Implementations
     // ------------------------------------------------------------------------
@@ -145,35 +127,35 @@
      */
     public NamingEnumeration<Object> getAll()
     {
-    	if ( size < 2 )
-    	{
-    		return new IteratorNamingEnumeration( new Iterator<Object>()
-    		{
-    			private boolean done = (size != 0);
-    				
-    			public boolean hasNext() 
-    			{
-    				return done;
-    			}
-    			
-    			public Object next() throws NoSuchElementException
-    			{
-    				done = false;
-    				return value;
-    			}
-    			
-    			public void remove() 
-    			{
-    				value = null;
-    				done = false;
-    				size = 0;
-    			}
-    		});
-    	}
-    	else
-    	{
-    		return new IteratorNamingEnumeration( list.iterator() );
-    	}
+        if ( size < 2 )
+        {
+            return new IteratorNamingEnumeration<Object>( new Iterator<Object>()
+            {
+                private boolean more = (size != 0);
+                    
+                public boolean hasNext() 
+                {
+                    return more;
+                }
+                
+                public Object next() 
+                {
+                    more = false;
+                    return value;
+                }
+                
+                public void remove() 
+                {
+                    value = null;
+                    more = true;
+                    size = 0;
+                }
+            });
+        }
+        else
+        {
+            return new IteratorNamingEnumeration<Object>( list.iterator() );
+        }
     }
 
 
@@ -184,18 +166,14 @@
      */
     public Object get()
     {
-    	if ( list == null )
-    	{
-    		return value;
-    	}
-    	else if ( list.isEmpty() )
+        if ( size < 2 )
         {
-            return null;
+            return value;
+        }
+        else
+        {
+            return list.get( 0 );
         }
-    	else
-    	{
-    		return list.get( 0 );
-    	}
     }
 
 
@@ -206,7 +184,7 @@
      */
     public int size()
     {
-    	return size;
+        return size;
     }
 
 
@@ -230,17 +208,27 @@
      */
     public boolean contains( Object attrVal )
     {
-    	switch (size)
-    	{
-    		case 0 :
-    			return false;
-    			
-    		case 1 :
-    			return value == null ? attrVal == null : value.equals( attrVal );
-    			
-    		default :
-    			return list.contains( attrVal );
-    	}
+        switch (size)
+        {
+            case 0 :
+                return false;
+                
+            case 1 :
+                return AttributeUtils.equals( value, attrVal );
+                
+            default :
+                Iterator values = list.iterator();
+            
+                while ( values.hasNext() )
+                {
+                    if ( AttributeUtils.equals( values.next(), attrVal ) )
+                    {
+                        return true;
+                    }
+                }
+                
+                return false;
+        }
     }
 
 
@@ -255,32 +243,49 @@
      */
     public boolean add( Object attrVal )
     {
-    	boolean exists = false;
-    	
-    	switch ( size )
-    	{
-    		case 0 :
-    			value = attrVal;
-    			size++;
-    			return true;
-    			
-    		case 1 :
-    			exists = value.equals( attrVal );
-
-    			list = new ArrayList<Object>();
-    			list.add( value );
-    			list.add( attrVal );
-    			size++;
-    			value = null;
-    			return exists;
-    			
-    		default :
-    			exists = list.contains( attrVal ); 
-    		
-    			list.add( attrVal );
-    			size++;
-    			return exists;
-    	}
+        boolean exists = false;
+        
+        if ( contains( attrVal ) )
+        {
+            // Do not duplicate values
+            return true;
+        }
+        
+        // First copy the value
+        attrVal = AttributeUtils.cloneValue( attrVal );
+        
+        switch ( size )
+        {
+            case 0 :
+                value = attrVal;
+                size++;
+                return true;
+                
+            case 1 :
+                exists = value.equals( attrVal );
+
+                if ( exists )
+                {
+                    // Don't add two times the same value
+                    return true;
+                }
+                else
+                {
+                    list = new ArrayList<Object>();
+                    list.add( value );
+                    list.add( attrVal );
+                    size++;
+                    value = null;
+                    return true;
+                }
+                
+            default :
+                exists = list.contains( attrVal ); 
+            
+                list.add( attrVal );
+                size++;
+                return exists;
+        }
     }
 
 
@@ -294,28 +299,28 @@
      */
     public boolean remove( Object attrVal )
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			return false;
-    			
-    		case 1 :
-    			value = null;
-    			size--;
-    			return true;
-    			
-    		case 2 :
-    			list.remove( attrVal );
-    			value = list.get(0);
-    			size = 1;
-    			list = null;
-    			return true;
-    			
-    		default :
-    			list.remove( attrVal );
-    			size--;
-    			return true;
-    	}
+        switch ( size )
+        {
+            case 0 :
+                return false;
+                
+            case 1 :
+                value = null;
+                size--;
+                return true;
+                
+            case 2 : 
+                list.remove( attrVal );
+                value = list.get(0);
+                size = 1;
+                list = null;
+                return true;
+                
+            default :
+                list.remove( attrVal );
+                size--;
+                return true;
+        }
     }
 
 
@@ -324,21 +329,21 @@
      */
     public void clear()
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			return;
-    			
-    		case 1 :
-    			value = null;
-    			size = 0;
-    			return;
-    			
-    		default :
-    			list = null;
-    			size = 0;
-    			return;
-    	}
+        switch ( size )
+        {
+            case 0 :
+                return;
+                
+            case 1 :
+                value = null;
+                size = 0;
+                return;
+                
+            default :
+                list = null;
+                size = 0;
+                return;
+        }
     }
 
 
@@ -374,24 +379,29 @@
     {
         try
         {
-            super.clone();
+            AttributeImpl clone = (AttributeImpl)super.clone();
+            
+            if ( size < 2 )
+            {
+                clone.value = AttributeUtils.cloneValue( value );
+            }
+            else
+            {
+                clone.list = new ArrayList<Object>( size );
+                
+                for ( int i = 0; i < size; i++ )
+                {
+                    Object newValue = AttributeUtils.cloneValue( list.get( i ) );
+                    clone.list.add( newValue );
+                }
+            }
+            
+            return clone;
         }
         catch ( CloneNotSupportedException cnse )
         {
-            // Just do nothing... Object is Cloneable
+            return null;
         }
-        
-    	switch ( size )
-    	{
-    		case 0 :
-    			return new LockableAttributeImpl( upId );
-    			
-    		case 1 :
-    			return new LockableAttributeImpl( upId, value );
-    			
-    		default :
-    			return new LockableAttributeImpl( upId, (List<Object>)((ArrayList<Object>)list).clone() );
-    	}
     }
 
 
@@ -416,17 +426,22 @@
      */
     public Object get( int index )
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			return null;
-    			
-    		case 1 :
-    			return value;
-    			
-    		default :
-    			return list.get( index );
-    	}
+        if ( (index < 0 ) || ( index > size + 1 ) )
+        {
+            return null;
+        }
+        
+        switch ( size )
+        {
+            case 0 :
+                return null;
+                
+            case 1 :
+                return value;
+                
+            default :
+                return list.get( index );
+        }
     }
 
 
@@ -440,21 +455,35 @@
      */
     public Object remove( int index )
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			return null;
-    			
-    		case 1 :
-    			Object result = value;
-    			value = null;
-    			size = 0;
-    			return result;
-    			
-    		default :
-    			size--;
-    			return list.remove( index );
-    	}
+        if ( (index < 0 ) || ( index > size + 1 ) )
+        {
+            return null;
+        }
+        
+        switch ( size )
+        {
+            case 0 :
+                return null;
+                
+            case 1 :
+                Object result = value;
+                value = null;
+                size = 0;
+                return result;
+                
+            case 2 :
+                Object removed = list.remove( index );
+                value = list.get(0);
+                size = 1;
+                list = null;
+                return removed;
+                
+                
+            default :
+                size--;
+            
+                return list.remove( index );
+        }
     }
 
 
@@ -469,36 +498,39 @@
      */
     public void add( int index, Object attrVal )
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			size++;
-    			value = attrVal;
-    			return;
-    			
-    		case 1 :
-    			list = new ArrayList<Object>();
-    			
-    			if ( index == 0 )
-    			{
-	    			list.add( attrVal );
-	    			list.add( value );
-    			}
-    			else
-    			{
-	    			list.add( value );
-	    			list.add( attrVal );
-    			}
-
-    			size++;
-    			value = null;
-    			return;
-    			
-    		default :
-    			list.add( index, attrVal );
-    			size++;
-    			return;
-    	}
+        // First copy the value
+        attrVal = AttributeUtils.cloneValue( attrVal );
+        
+        switch ( size )
+        {
+            case 0 :
+                size++;
+                value = attrVal;
+                return;
+                
+            case 1 :
+                list = new ArrayList<Object>();
+                
+                if ( index == 0 )
+                {
+                    list.add( attrVal );
+                    list.add( value );
+                }
+                else
+                {
+                    list.add( value );
+                    list.add( attrVal );
+                }
+
+                size++;
+                value = null;
+                return;
+                
+            default :
+                list.add( index, attrVal );
+                size++;
+                return;
+        }
     }
 
 
@@ -513,35 +545,38 @@
      */
     public Object set( int index, Object attrVal )
     {
-    	switch ( size )
-    	{
-    		case 0 :
-    			size++;
-    			value = attrVal;
-    			return null;
-    			
-    		case 1 :
-    			if ( index == 0 )
-    			{
-	    			Object result = value;
-	    			value = attrVal;
-	    			return result;
-    			}
-    			else
-    			{
-    				list = new ArrayList<Object>();
-    				list.add( value );
-    				list.add( attrVal );
-    				size = 2;
-    				value = null;
-    				return null;
-    			}
-    			
-    		default :
-    			Object oldValue = list.get( index );
-    			list.set( index, attrVal );
-    			return oldValue;
-    	}
+        // First copy the value
+        attrVal = AttributeUtils.cloneValue( attrVal );
+        
+        switch ( size )
+        {
+            case 0 :
+                size++;
+                value = attrVal;
+                return null;
+                
+            case 1 :
+                if ( index == 0 )
+                {
+                    Object result = value;
+                    value = attrVal;
+                    return result;
+                }
+                else
+                {
+                    list = new ArrayList<Object>();
+                    list.add( value );
+                    list.add( attrVal );
+                    size = 2;
+                    value = null;
+                    return null;
+                }
+                
+            default :
+                Object oldValue = list.get( index );
+                list.set( index, attrVal );
+                return oldValue;
+        }
     }
 
 
@@ -566,7 +601,7 @@
             return true;
         }
 
-        if ( ( obj == null ) || !( obj instanceof Attribute ) )
+        if ( ( obj == null ) || !( obj instanceof AttributeImpl ) )
         {
             return false;
         }
@@ -583,131 +618,185 @@
             return false;
         }
 
-        switch ( size )
+        if ( size == 0 )
+        {
+            return true;
+        }
+        else if ( size == 1 )
         {
-        	case 0 :
-        		return true;
-        		
-        	case 1 :
-                try
+            try
+            {
+                return ( value.equals( attr.get( 0 ) ) );
+            }
+            catch ( NamingException ne )
+            {
+                log.warn( "Failed to get an attribute from the specifid attribute: " + attr, ne );
+                return false;
+            }
+        }
+        else
+        {
+            // We have to create one hashSet to store all the values
+            // of the current attribute, and we will remove from this
+            // hashSet all the values from the second attribute which
+            // are present. At the end, the hashSet should be empty,
+            // and we should not have any value remaining in the second
+            // attribute. If not, that means the attributes are not
+            // equals.
+            //
+            // We have to do that because attribute's values are
+            // not ordered.
+            Map<Integer, Object> hash = new HashMap<Integer, Object>();
+            
+            for ( Object v:list )
+            {
+                int h = 0;
+                
+                if ( v instanceof String )
+                {
+                    h = v.hashCode();
+                }
+                else if ( v instanceof byte[] )
                 {
-                	return value.equals( attr.get( 0 ) );
+                    byte[] bv = (byte[])v;
+                    h = Arrays.hashCode( bv );
                 }
-                catch ( NamingException e )
+                else
                 {
-                    log.warn( "Failed to get an attribute from the specifid attribute: " + attr, e );
                     return false;
                 }
-        		
-        	default :
-                for ( int i = 0; i < size; i++ )
+                
+                hash.put( Integer.valueOf( h ), v );
+            }
+            
+            try
+            {
+                NamingEnumeration attrValues = attr.getAll();
+                
+                while ( attrValues.hasMoreElements() )
                 {
-                    try
+                    Object val = attrValues.next();
+                    
+                    if ( val instanceof String )
                     {
-                        if ( !list.contains( attr.get( i ) ) )
+                        Integer h = Integer.valueOf( val.hashCode() );
+                        
+                        if ( !hash.containsKey( h ) )
                         {
                             return false;
                         }
+                        else
+                        {
+                            Object val2 = hash.remove( h );
+                            
+                            if ( !val.equals( val2 ) )
+                            {
+                                return false;
+                            }
+                        }
                     }
-                    catch ( NamingException e )
+                    else if ( val instanceof byte[] )
+                    {
+                        Integer h = Integer.valueOf( Arrays.hashCode( (byte[])val ) );
+
+                        if ( !hash.containsKey( h ) )
+                        {
+                            return false;
+                        }
+                        else
+                        {
+                            Object val2 = hash.remove( h );
+                            
+                            if ( !Arrays.equals( (byte[])val, (byte[])val2 ) )
+                            {
+                                return false;
+                            }
+                        }
+                    }
+                    else
                     {
-                        log.warn( "Failed to get an attribute from the specifid attribute: " + attr, e );
                         return false;
                     }
                 }
-        		
-        		return true;
+                
+                if ( hash.size() != 0 )
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+            catch ( NamingException ne )
+            {
+                log.warn( "Failed to get an attribute from the specifid attribute: " + attr, ne );
+                return false;
+            }
         }
     }
-
+    
     /**
-     * @see Object#hashCode()
+     * @see Object#toString()
      */
-    public int hashCode()
+    public String toString()
     {
-        int hash = 7;
-        hash = hash*31 + size;
-        hash = hash*31 + ( upId == null ? 0 : upId.hashCode() );
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append( "Attribute id : '" ).append( upId ).append( "', " );
+        sb.append( " Values : [");
         
         switch (size)
         {
             case 0 :
-                return hash;
+                sb.append( "]\n" );
+                break;
                 
             case 1 :
-                return hash*31 + ( value == null ? 0 : value.hashCode() );
+                if ( value instanceof String ) 
+                {
+                    sb.append( '\'' ).append( value ).append( '\'' );
+                }
+                else
+                {
+                    sb.append( StringTools.dumpBytes( (byte[])value ) );
+                }
+                
+                sb.append( "]\n" );
+                break;
                 
             default :
-                for ( Object value:list )
+                boolean isFirst = true;
+            
+                Iterator values = list.iterator();
+                
+                while ( values.hasNext() )
                 {
-                    hash = hash*31 + ( value == null ? 0 : value.hashCode() );
+                    Object v = values.next();
+                    
+                    if ( isFirst == false )
+                    {
+                        sb.append( ", " );
+                    }
+                    else
+                    {
+                        isFirst = false;
+                    }
+                    
+                    if ( v instanceof String ) 
+                    {
+                        sb.append( '\'' ).append( v ).append( '\'' );
+                    }
+                    else
+                    {
+                        sb.append( StringTools.dumpBytes( (byte[])v ) );
+                    }
                 }
-            
-                return hash;
+                
+                sb.append( "]\n" );
+                break;
         }
-    }
-
-    /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-    	StringBuffer sb = new StringBuffer();
-    	
-    	sb.append( "Attribute id : '" ).append( upId ).append( "', " );
-    	sb.append( " Values : [");
-    	
-    	switch (size)
-    	{
-    		case 0 :
-    			sb.append( "]\n" );
-    			break;
-    			
-    		case 1 :
-    			if ( value instanceof String ) 
-    			{
-    				sb.append( '\'' ).append( value ).append( '\'' );
-				}
-    			else
-    			{
-    				sb.append( StringTools.dumpBytes( (byte[])value ) );
-    			}
-    			
-    			sb.append( "]\n" );
-    			break;
-    			
-    		default :
-    			boolean isFirst = true;
-    		
-	    		Iterator values = list.iterator();
-	    		
-	    		while ( values.hasNext() )
-	    		{
-	    			Object v = values.next();
-	    			
-	    			if ( isFirst == false )
-	    			{
-	    				sb.append( ", " );
-	    			}
-	    			else
-	    			{
-	    				isFirst = false;
-	    			}
-	    			
-	    			if ( v instanceof String ) 
-	    			{
-	    				sb.append( '\'' ).append( v ).append( '\'' );
-					}
-	    			else
-	    			{
-	    				sb.append( StringTools.dumpBytes( (byte[])v ) );
-	    			}
-	    		}
-	    		
-	    		sb.append( "]\n" );
-	    		break;
-    	}
-    	
-    	return sb.toString();
+        
+        return sb.toString();
     }
 }

Copied: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java (from r494042, directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java)
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java?view=diff&rev=494173&p1=directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java&r1=494042&p2=directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/AttributesImpl.java Mon Jan  8 11:42:35 2007
@@ -31,6 +31,7 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
 
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 
@@ -40,119 +41,149 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class LockableAttributesImpl implements Attributes, Serializable
+public class AttributesImpl implements Attributes
 {
-    static transient final long serialVersionUID = -69864533495992471L;
+    static transient final long serialVersionUID = 1L;
+    
+    /** This flag is used if the attribute name is not caseSensitive */
+    private boolean ignoreCase;
 
     /**
      * An holder to store <Id, Attribute> couples
-     * 
      */
     private class Holder implements Serializable, Cloneable
-	{
-    	static transient final long serialVersionUID = 1L;
-    	
-		String upId;
-		Attribute attribute;
-		
-		private Holder( String upId, Attribute attribute )
-		{
-			this.upId = upId;
-			this.attribute = attribute;
-		}
-		
+    {
+        static transient final long serialVersionUID = 1L;
+        
+        // The user provided attribute ID
+        private String upId;
+        
+        // The attribute. Should be an instance of LockableAttribute
+        private Attribute attribute;
+        
+        /**
+         * Create a new holder for the given ID
+         * @param upId The attribute UP id
+         * @param attribute The attribute
+         */
+        private Holder( String upId, Attribute attribute )
+        {
+            this.upId = upId;
+            this.attribute = attribute;
+        }
+        
+        /**
+         * @see Object#clone()
+         */
         public Object clone() throws CloneNotSupportedException
-		{
-			Holder clone = (Holder)super.clone();
-			
-			clone.upId = upId;
-			clone.attribute = (Attribute)attribute.clone();
-			
-			return clone;
-		}
-		
-		public String toString()
-		{
-			StringBuffer sb = new StringBuffer();
-			
-			sb.append( upId ).append( ": " );
-			
-			sb.append( attribute ).append( '\n' );
-			
-			return sb.toString();
-		}
-        
-        public int hashCode()
-        {
-            int hash = 7;
-            hash = hash*31 + ( upId == null ? 0 : upId.hashCode() );
-            hash = hash*31 + (attribute == null ? 0 : attribute.hashCode() );
+        {
+            Holder clone = (Holder)super.clone();
             
-            return hash;
+            clone.upId = upId;
+            
+            if ( attribute instanceof BasicAttribute )
+            {
+                // The BasicAttribute clone() method does not
+                // copy the values.
+                clone.attribute = new AttributeImpl( attribute.getID() );
+                
+                try
+                {
+                    NamingEnumeration values = attribute.getAll();
+                    
+                    while ( values.hasMoreElements() )
+                    {
+                        clone.attribute.add( AttributeUtils.cloneValue( values.nextElement() ) );
+                    }
+                }
+                catch( NamingException ne )
+                {
+                    
+                }
+            }
+            clone.attribute = (Attribute)attribute.clone();
+            
+            return clone;
         }
-	}
-	
+        
+        /**
+         * @see Object#toString()
+         */
+        public String toString()
+        {
+            StringBuffer sb = new StringBuffer();
+            
+            sb.append( upId ).append( ": " );
+            
+            sb.append( attribute ).append( '\n' );
+            
+            return sb.toString();
+        }
+    }
+    
     /**
      * An iterator which returns Attributes.  
      */
-	public class AttributeIterator implements Iterator
-	{
-		private Iterator iterator; 
-		
-		private AttributeIterator( LockableAttributesImpl attributes )
-		{
-			iterator = attributes.keyMap.values().iterator();
-		}
-		
-	    /**
-	     * Returns <tt>true</tt> if the iteration has more elements. (In other
-	     * words, returns <tt>true</tt> if <tt>next</tt> would return an element
-	     * rather than throwing an exception.)
-	     *
-	     * @return <tt>true</tt> if the iterator has more elements.
-	     */
-	    public boolean hasNext()
-	    {
-	    	return iterator.hasNext();
-	    }
-
-	    /**
-	     * Returns the next element in the iteration.  Calling this method
-	     * repeatedly until the {@link #hasNext()} method returns false will
-	     * return each element in the underlying collection exactly once.
-	     *
-	     * @return the next element in the iteration.
-	     * @exception NoSuchElementException iteration has no more elements.
-	     */
-	    public Object next()
-	    {
-	    	return ((Holder)iterator.next()).attribute;
-	    }
-
-	    /**
-	     * 
-	     * Removes from the underlying collection the last element returned by the
-	     * iterator (optional operation).  This method can be called only once per
-	     * call to <tt>next</tt>.  The behavior of an iterator is unspecified if
-	     * the underlying collection is modified while the iteration is in
-	     * progress in any way other than by calling this method.
-	     *
-	     * @exception UnsupportedOperationException if the <tt>remove</tt>
-	     *		  operation is not supported by this Iterator.
-	     
-	     * @exception IllegalStateException if the <tt>next</tt> method has not
-	     *		  yet been called, or the <tt>remove</tt> method has already
-	     *		  been called after the last call to the <tt>next</tt>
-	     *		  method.
-	     */
-	    public void remove()
-	    {
-	    	iterator.remove();
-	    }
-	}
-	
+    public class AttributeIterator<T> implements Iterator<Attribute>
+    {
+        /** The internal iterator */
+        private Iterator<Holder> iterator; 
+        
+        /** Create an attribute's iterator */
+        private AttributeIterator( AttributesImpl attributes )
+        {
+            iterator = attributes.keyMap.values().iterator();
+        }
+        
+        /**
+         * Returns <tt>true</tt> if the iteration has more elements. (In other
+         * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+         * rather than throwing an exception.)
+         *
+         * @return <tt>true</tt> if the iterator has more elements.
+         */
+        public boolean hasNext()
+        {
+            return iterator.hasNext();
+        }
+
+        /**
+         * Returns the next element in the iteration.  Calling this method
+         * repeatedly until the {@link #hasNext()} method returns false will
+         * return each element in the underlying collection exactly once.
+         *
+         * @return the next element in the iteration.
+         * @exception NoSuchElementException iteration has no more elements.
+         */
+        public Attribute next()
+        {
+            return iterator.next().attribute;
+        }
+
+        /**
+         * 
+         * Removes from the underlying collection the last element returned by the
+         * iterator (optional operation).  This method can be called only once per
+         * call to <tt>next</tt>.  The behavior of an iterator is unspecified if
+         * the underlying collection is modified while the iteration is in
+         * progress in any way other than by calling this method.
+         *
+         * @exception UnsupportedOperationException if the <tt>remove</tt>
+         *        operation is not supported by this Iterator.
+         
+         * @exception IllegalStateException if the <tt>next</tt> method has not
+         *        yet been called, or the <tt>remove</tt> method has already
+         *        been called after the last call to the <tt>next</tt>
+         *        method.
+         */
+        public void remove()
+        {
+            iterator.remove();
+        }
+    }
+    
     /** Cache of lowercase id Strings to mixed cased user provided String ids */
-    Map<String, Holder> keyMap;
+    private Map<String, Holder> keyMap;
 
 
     // ------------------------------------------------------------------------
@@ -160,11 +191,41 @@
     // ------------------------------------------------------------------------
 
     /**
-     * Creates a LockableAttributes without a parent Lockable.
+     * Creates an Attributes
+     */
+    public AttributesImpl()
+    {
+        keyMap = new HashMap<String, Holder>();
+        ignoreCase = true;
+    }
+
+    /**
+     * Creates an Attributes
+     */
+    public AttributesImpl( boolean ignoreCase )
+    {
+        keyMap = new HashMap<String, Holder>();
+        this.ignoreCase = ignoreCase;
+    }
+
+    /**
+     * Creates an Attributes with one Attribute
      */
-    public LockableAttributesImpl()
+    public AttributesImpl( String id, Object value )
     {
         keyMap = new HashMap<String, Holder>();
+        put( id, value );
+        ignoreCase = true;
+    }
+
+    /**
+     * Creates an Attributes with one attribute
+     */
+    public AttributesImpl(  String id, Object value, boolean ignoreCase )
+    {
+        keyMap = new HashMap<String, Holder>();
+        put( id, value );
+        this.ignoreCase = ignoreCase;
     }
 
     // ------------------------------------------------------------------------
@@ -181,41 +242,41 @@
     // The streamed value will looks like :
     // [nbAttrs:int]
     //   (
-    //		[length attributeType(i):int] [attributeType(i):String] 
-    //		[length attributeTypeUP(i):int] [attributeTypeUP(i):String]
-    //		[attributeValues(i)]
-    //	 )*
+    //      [length attributeType(i):int] [attributeType(i):String] 
+    //      [length attributeTypeUP(i):int] [attributeTypeUP(i):String]
+    //      [attributeValues(i)]
+    //   )*
     //
     // The attribute value is streamed by the LockableAttributeImpl class.
     // ------------------------------------------------------------------------
     /*public void readObject( ObjectInputStream oi ) throws IOException, ClassNotFoundException
     {
-    	oi.defaultReadObject();
-    	
-    	// Read the map size
-    	int size = oi.readInt();
-    	
-    	keyMap = new HashMap( size );
-    	
-    	for ( int i = 0; i < size(); i++ )
-    	{
-    		int keySize = oi.readInt();
-    		char[] keyChars = new char[keySize];
-    		
-    		for ( int j = 0; j < keySize; j++)
-    		{
-    			keyChars[j] = oi.readChar();
-    		}
-    		
-    		String upId = new String( keyChars );
-    		String key = upId.toLowerCase();
-    		
-    		Attribute attribute = (LockableAttributeImpl)oi.readObject();
-    		
-    		Holder holder = new Holder( upId, attribute);
-    		
-    		keyMap.put( key, holder );
-    	}
+        oi.defaultReadObject();
+        
+        // Read the map size
+        int size = oi.readInt();
+        
+        keyMap = new HashMap( size );
+        
+        for ( int i = 0; i < size(); i++ )
+        {
+            int keySize = oi.readInt();
+            char[] keyChars = new char[keySize];
+            
+            for ( int j = 0; j < keySize; j++)
+            {
+                keyChars[j] = oi.readChar();
+            }
+            
+            String upId = new String( keyChars );
+            String key = upId.toLowerCase();
+            
+            Attribute attribute = (LockableAttributeImpl)oi.readObject();
+            
+            Holder holder = new Holder( upId, attribute);
+            
+            keyMap.put( key, holder );
+        }
     }*/
 
     /**
@@ -223,30 +284,30 @@
      */
     /*private void writeObject( ObjectOutputStream oo ) throws IOException
     {
-    	oo.defaultWriteObject();
-    	
-    	// Write the map size
-    	oo.write( keyMap.size() );
-    	
-    	Iterator keys = keyMap.keySet().iterator(); 
-    	
-    	while ( keys.hasNext() )
-    	{
-    		String key = (String)keys.next();
-    		Holder holder = (Holder)keyMap.get( key );
-
-    		// Write the userProvided key
-    		// No need to write the key, it will be
-    		// rebuilt by the read operation
-    		oo.write( holder.upId.length() );
-    		oo.writeChars( holder.upId );
-    		
-    		// Recursively call the writeExternal metho
-    		// of the attribute object
-    		oo.writeObject( holder.attribute );
-    	}
-    	
-    	// That's it !
+        oo.defaultWriteObject();
+        
+        // Write the map size
+        oo.write( keyMap.size() );
+        
+        Iterator keys = keyMap.keySet().iterator(); 
+        
+        while ( keys.hasNext() )
+        {
+            String key = (String)keys.next();
+            Holder holder = (Holder)keyMap.get( key );
+
+            // Write the userProvided key
+            // No need to write the key, it will be
+            // rebuilt by the read operation
+            oo.write( holder.upId.length() );
+            oo.writeChars( holder.upId );
+            
+            // Recursively call the writeExternal metho
+            // of the attribute object
+            oo.writeObject( holder.attribute );
+        }
+        
+        // That's it !
     }*/
 
     // ------------------------------------------------------------------------
@@ -261,7 +322,7 @@
      */
     public boolean isCaseIgnored()
     {
-        return true;
+        return ignoreCase;
     }
 
 
@@ -290,15 +351,15 @@
      */
     public Attribute get( String attrId )
     {
-    	if ( attrId != null )
-    	{
-    		Holder holder = keyMap.get( StringTools.toLowerCase( attrId ) );
-    		return holder != null ? holder.attribute : null;
-    	}
-    	else
-    	{
-    		return null;
-    	}
+        if ( attrId != null )
+        {
+            Holder holder = keyMap.get( StringTools.toLowerCase( attrId ) );
+            return holder != null ? holder.attribute : null;
+        }
+        else
+        {
+            return null;
+        }
     }
 
 
@@ -314,7 +375,7 @@
      */
     public NamingEnumeration<Attribute> getAll()
     {
-        return new IteratorNamingEnumeration( new AttributeIterator( this ) );
+        return new IteratorNamingEnumeration<Attribute>( new AttributeIterator<Attribute>( this ) );
     }
 
 
@@ -330,17 +391,17 @@
      */
     public NamingEnumeration<String> getIDs()
     {
-    	String[] ids = new String[keyMap.size()];
-    	
-    	Iterator values = keyMap.values().iterator();
-    	int i = 0;
-    	
-    	while ( values.hasNext() )
-    	{
-    		ids[i++] = ((Holder)values.next()).upId;
-    	}
-    	
-        return new ArrayNamingEnumeration( ids );
+        String[] ids = new String[keyMap.size()];
+        
+        Iterator values = keyMap.values().iterator();
+        int i = 0;
+        
+        while ( values.hasNext() )
+        {
+            ids[i++] = ((Holder)values.next()).upId;
+        }
+        
+        return new ArrayNamingEnumeration<String>( ids );
     }
 
 
@@ -360,7 +421,7 @@
      */
     public Attribute put( String attrId, Object val )
     {
-        Attribute attr = new LockableAttributeImpl( attrId );
+        Attribute attr = new AttributeImpl( attrId );
         attr.add( val );
         
         String key = StringTools.toLowerCase( attrId );
@@ -376,43 +437,47 @@
      *            The non-null attribute to add. If the attribute set ignores
      *            the character case of its attribute ids, the case of attr's
      *            identifier is ignored.
+     *            The store attribute is a clone of the given attribute.
      * @return The Attribute with the same ID as attr that was previous in this
      *         attribute set; The new attr if no such attribute existed.
      * @see #remove
      */
     public Attribute put( Attribute attr )
     {
-    	String key = StringTools.toLowerCase( attr.getID() );
-    	Attribute old = null;
-    	Attribute newAttr = attr;
-    	
+        String key = StringTools.toLowerCase( attr.getID() );
+        Attribute old = null;
+        Attribute newAttr = attr;
+        
         if ( keyMap.containsKey( key ) )
         {
             old = keyMap.remove( key ).attribute;
         }
         else
         {
-        	old = attr;
+            old = attr;
         }
 
-        if ( attr instanceof BasicAttribute )
+        if ( attr instanceof AttributeImpl )
         {
-        	 newAttr = new LockableAttributeImpl( attr.getID() );
-        	 
-        	 try
-        	 {
-	        	 NamingEnumeration values = attr.getAll();
-	        	 
-	        	 while ( values.hasMore() )
-	        	 {
-	        		 Object value = values.next();
-	        		 newAttr.add( value );
-	        	 }
-        	 }
-        	 catch ( NamingException ne )
-        	 {
-        		 // do nothing
-        	 }
+            newAttr = attr;
+        }
+        else if ( attr instanceof BasicAttribute )
+        {
+            newAttr = new AttributeImpl( attr.getID() );
+             
+            try
+            {
+                NamingEnumeration values = attr.getAll();
+                 
+                while ( values.hasMore() )
+                {
+                    newAttr.add( AttributeUtils.cloneValue( values.next() ) );
+                }
+            }
+            catch ( NamingException ne )
+            {
+                // do nothing
+            }
         }
         
         keyMap.put( key, new Holder( attr.getID(), newAttr ) );
@@ -433,20 +498,25 @@
      */
     public Attribute remove( String attrId )
     {
-    	String key = StringTools.toLowerCase( attrId );
-    	Attribute old = null;
-    	
+        String key = StringTools.toLowerCase( attrId );
+        
         if ( keyMap.containsKey( key ) )
         {
-        	Holder holder = keyMap.remove( key );
-        	
-        	if ( holder != null ) 
-        	{
-        		old = holder.attribute;
-        	}
+            Holder holder = keyMap.remove( key );
+            
+            if ( holder != null ) 
+            {
+                return holder.attribute;
+            }
+            else
+            {
+                return null;
+            }
+        }
+        else
+        {
+            return null;
         }
-
-        return old;
     }
 
 
@@ -458,24 +528,27 @@
      */
     public Object clone()
     {
-    	try
-    	{
-	    	LockableAttributesImpl clone = (LockableAttributesImpl)super.clone();
-	
-			clone.keyMap = (Map<String, Holder>)(((HashMap<String, Holder>)keyMap).clone());
-			
-            for ( String key:keyMap.keySet() )
-	        {
-	        	Holder holder = keyMap.get( key );
-	            clone.keyMap.put( key, (Holder)holder.clone() );
-	        }
-	    	
-	        return clone;
-    	}
-    	catch ( CloneNotSupportedException cnse )
-    	{
-    		return null;
-    	}
+        try
+        {
+            AttributesImpl clone = (AttributesImpl)super.clone();
+    
+            clone.keyMap = new HashMap<String, Holder>( keyMap.size() );
+            
+            Iterator keys = keyMap.keySet().iterator();
+    
+            while ( keys.hasNext() )
+            {
+                String key = (String)keys.next();
+                Holder holder = keyMap.get( key );
+                clone.keyMap.put( key, (Holder)holder.clone() );
+            }
+            
+            return clone;
+        }
+        catch ( CloneNotSupportedException cnse )
+        {
+            return null;
+        }
     }
 
 
@@ -492,7 +565,7 @@
         
         while ( attrs.hasNext() )
         {
-        	Holder holder = (Holder)attrs.next();
+            Holder holder = (Holder)attrs.next();
             Attribute attr = holder.attribute;
 
             buf.append( holder.upId );
@@ -521,7 +594,7 @@
             return true;
         }
 
-        if ( ( obj == null ) || !( obj instanceof Attributes ) )
+        if ( ( obj == null ) || !( obj instanceof AttributesImpl ) )
         {
             return false;
         }
@@ -542,7 +615,7 @@
 
         while ( list.hasMoreElements() )
         {
-            Attribute attr = ( Attribute ) list.nextElement();
+            Attribute attr = ( Attribute )list.nextElement();
             Attribute myAttr = get( attr.getID() );
 
             if ( myAttr == null )
@@ -557,14 +630,5 @@
         }
 
         return true;
-    }
-    
-    /**
-     * @see Object#hashCode()
-     */
-    public int hashCode()
-    {
-        int hash = 7;
-        return hash*31 + keyMap.hashCode();
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/IteratorNamingEnumeration.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/IteratorNamingEnumeration.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/IteratorNamingEnumeration.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/IteratorNamingEnumeration.java Mon Jan  8 11:42:35 2007
@@ -31,10 +31,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
-public class IteratorNamingEnumeration implements NamingEnumeration
+public class IteratorNamingEnumeration<T> implements NamingEnumeration<T>
 {
     /** the iterator to wrap as in the enumeration */
-    private final Iterator m_iterator;
+    private Iterator<T> iterator;
 
 
     /**
@@ -43,9 +43,9 @@
      * @param a_iterator
      *            the Iterator the NamingEnumeration is based on.
      */
-    public IteratorNamingEnumeration(final Iterator a_iterator)
+    public IteratorNamingEnumeration( Iterator<T> iterator)
     {
-        m_iterator = a_iterator;
+        this.iterator = iterator;
     }
 
 
@@ -58,16 +58,16 @@
      */
     public boolean hasMoreElements()
     {
-        return m_iterator.hasNext();
+        return iterator.hasNext();
     }
 
 
     /**
      * @see java.util.Enumeration#nextElement()
      */
-    public Object nextElement()
+    public T nextElement()
     {
-        return m_iterator.next();
+        return iterator.next();
     }
 
 
@@ -89,15 +89,15 @@
      */
     public boolean hasMore()
     {
-        return m_iterator.hasNext();
+        return iterator.hasNext();
     }
 
 
     /**
      * @see javax.naming.NamingEnumeration#next()
      */
-    public Object next()
+    public T next()
     {
-        return m_iterator.next();
+        return iterator.next();
     }
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequest.java?view=diff&rev=494173&r1=494172&r2=494173
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequest.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyRequest.java Mon Jan  8 11:42:35 2007
@@ -22,7 +22,6 @@
 
 import java.util.Collection;
 
-import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.shared.ldap.name.LdapDN;
 
@@ -141,7 +140,7 @@
      * @param mod
      *            a ModificationItem to add.
      */
-    void addModification( ModificationItem mod );
+    void addModification( ModificationItemImpl mod );
 
 
     /**
@@ -151,5 +150,5 @@
      * @param mod
      *            a ModificationItem to remove.
      */
-    void removeModification( ModificationItem mod );
+    void removeModification( ModificationItemImpl mod );
 }



Mime
View raw message