directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r267368 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
Date Sat, 03 Sep 2005 01:14:54 GMT
Author: elecharny
Date: Fri Sep  2 18:14:50 2005
New Revision: 267368

URL: http://svn.apache.org/viewcvs?rev=267368&view=rev
Log:
Changed the ArrayList containing the attributes to javax.naming.directory.Attributes

Modified:
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java

Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java?rev=267368&r1=267367&r2=267368&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
(original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
Fri Sep  2 18:14:50 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.asn1new.ldap.pojo;
 
-import org.apache.asn1new.Asn1Object;
 import org.apache.asn1.codec.EncoderException;
 import org.apache.asn1new.ber.tlv.Length;
 import org.apache.asn1new.ber.tlv.UniversalTag;
@@ -28,8 +27,12 @@
 
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
 
 /**
  * A SearchRequest ldapObject. It's a sub-class of Asn1Object, and it implements
@@ -69,7 +72,7 @@
     private Filter filter;
 
     /** The list of attributes to get */
-    private ArrayList attributes;
+    private Attributes attributes;
 
     /** The current filter. This is used while decoding a PDU */
     private transient Filter currentFilter;
@@ -109,7 +112,7 @@
      *
      * @return Returns the attributes.
      */
-    public ArrayList getAttributes()
+    public Attributes getAttributes()
     {
         return attributes;
     }
@@ -121,7 +124,7 @@
      */
     public void addAttribute( LdapString attribute )
     {
-        attributes.add( attribute );
+        attributes.put( new BasicAttribute( attribute.toString().toLowerCase() ) );
     }
 
     /**
@@ -129,7 +132,7 @@
      */
     public void initAttributes()
     {
-        attributes = new ArrayList();
+        attributes = new BasicAttributes( true );
     }
 
     /**
@@ -346,15 +349,16 @@
         
         if ( ( attributes != null ) && ( attributes.size() != 0 ) )
         {
-            Iterator attributeIterator = attributes.iterator();
+            NamingEnumeration attributeIterator = attributes.getAll();
             
             // Compute the attributes length
-            while ( attributeIterator.hasNext() )
+            while ( attributeIterator.hasMoreElements() )
             {
-                LdapString attribute = (LdapString)attributeIterator.next();
+                Attribute attribute = (BasicAttribute)attributeIterator.nextElement();
                 
                 // add the attribute length to the attributes length
-                attributeDescriptionListLength += 1 + Length.getNbBytes( attribute.getLength()
) + attribute.getLength();
+                int idLength = attribute.getID().getBytes().length;
+                attributeDescriptionListLength += 1 + Length.getNbBytes( idLength ) + idLength;
             }
         }
         
@@ -425,14 +429,14 @@
             
             if ( ( attributes != null ) && ( attributes.size() != 0 ) )
             {
-                Iterator attributeIterator = attributes.iterator();
+                NamingEnumeration attributeIterator = attributes.getAll();
                 
                 // encode each attribute
-                while ( attributeIterator.hasNext() )
+                while ( attributeIterator.hasMoreElements() )
                 {
-                    LdapString attribute = (LdapString)attributeIterator.next();
+                    Attribute attribute = (BasicAttribute)attributeIterator.nextElement();
                     
-                    Value.encode( buffer, attribute );
+                    Value.encode( buffer, attribute.getID() );
                 }
             }
         }



Mime
View raw message