You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/08/28 18:42:09 UTC
svn commit: r263885 - in
/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src:
java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
test/org/apache/asn1new/ldap/codec/AddRequestTest.java
Author: elecharny
Date: Sun Aug 28 09:41:51 2005
New Revision: 263885
URL: http://svn.apache.org/viewcvs?rev=263885&view=rev
Log:
Changed the ArrayList to an Attributes.
Modified:
directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java
Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java?rev=263885&r1=263884&r2=263885&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java (original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java Sun Aug 28 09:41:51 2005
@@ -30,15 +30,15 @@
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
/**
@@ -71,7 +71,7 @@
private LdapDN entry;
/** The attributes list. */
- private ArrayList attributes;
+ private Attributes attributes;
/** The current attribute being decoded */
private transient Attribute currentAttribute;
@@ -115,7 +115,7 @@
*/
public void initAttributes()
{
- attributes = new ArrayList();
+ attributes = new BasicAttributes( true );
}
/**
@@ -123,7 +123,7 @@
*
* @return Returns the attributes.
*/
- public ArrayList getAttributes()
+ public Attributes getAttributes()
{
return attributes;
}
@@ -136,7 +136,7 @@
public void addAttributeType( LdapString type )
{
currentAttribute = new BasicAttribute( type.toString().toLowerCase() );
- attributes.add( currentAttribute );
+ attributes.put( currentAttribute );
}
/**
@@ -219,14 +219,14 @@
if ( ( attributes != null ) && ( attributes.size() != 0 ) )
{
- Iterator attributeIterator = attributes.iterator();
+ NamingEnumeration attributeIterator = attributes.getAll();
attributeLength = new LinkedList();
valuesLength = new LinkedList();
// Compute the attributes length
- while ( attributeIterator.hasNext() )
+ while ( attributeIterator.hasMoreElements() )
{
- Attribute attribute = (Attribute)attributeIterator.next();
+ Attribute attribute = (Attribute)attributeIterator.nextElement();
int localAttributeLength = 0;
int localValuesLength = 0;
@@ -321,13 +321,13 @@
// The partial attribute list
if ( ( attributes != null ) && ( attributes.size() != 0 ) )
{
- Iterator attributeIterator = attributes.iterator();
+ NamingEnumeration attributeIterator = attributes.getAll();
int attributeNumber = 0;
// Compute the attributes length
- while ( attributeIterator.hasNext() )
+ while ( attributeIterator.hasMoreElements() )
{
- Attribute attribute = (Attribute)attributeIterator.next();
+ Attribute attribute = (Attribute)attributeIterator.nextElement();
// The attributes list sequence
buffer.put( UniversalTag.SEQUENCE_TAG );
@@ -392,13 +392,13 @@
{
sb.append( " Attributes\n" );
- for ( int i = 0; i < attributes.size(); i++ )
+ NamingEnumeration attributesIterator = attributes.getAll();
+
+ while (attributesIterator.hasMoreElements())
{
+ Attribute attribute = ( Attribute ) attributesIterator.nextElement();
- Attribute attribute = ( Attribute ) attributes.get( i );
-
- sb.append( " Type[" ).append( i ).append( "] : '" )
- .append( attribute.getID() ).append( "'\n" );
+ sb.append( " Type : '" ).append( attribute.getID() ).append( "'\n" );
for ( int j = 0; j < attribute.size(); j++ )
{
Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java?rev=263885&r1=263884&r2=263885&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java (original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/test/org/apache/asn1new/ldap/codec/AddRequestTest.java Sun Aug 28 09:41:51 2005
@@ -23,6 +23,7 @@
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import org.apache.asn1.codec.DecoderException;
@@ -112,7 +113,7 @@
Assert.assertEquals( 1, message.getMessageId() );
Assert.assertEquals( "cn=testModify, ou=users, ou=system", addRequest.getEntry() );
- ArrayList attributes = addRequest.getAttributes();
+ Attributes attributes = addRequest.getAttributes();
Assert.assertEquals( 2, attributes.size() );
@@ -133,7 +134,7 @@
lVal2.add("test3");
typesVals.put("attrs", lVal2);
- BasicAttribute attributeValue = (BasicAttribute)attributes.get( 0 );
+ BasicAttribute attributeValue = (BasicAttribute)attributes.get( "l" );
Assert.assertTrue( expectedTypes.contains( attributeValue.getID().toLowerCase() ) );
@@ -149,7 +150,7 @@
vals.remove( value.toString() );
}
- attributeValue = (BasicAttribute)attributes.get( 1 );
+ attributeValue = (BasicAttribute)attributes.get( "attrs" );
Assert.assertTrue( expectedTypes.contains( attributeValue.getID().toLowerCase() ) );