You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/02/06 11:28:14 UTC
svn commit: r151566 -
incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
Author: trustin
Date: Sun Feb 6 02:28:13 2005
New Revision: 151566
URL: http://svn.apache.org/viewcvs?view=rev&rev=151566
Log:
Fixed: Asn1CodecEncoder didn't handle encoded arrays and encoded collections.
Modified:
incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
Modified: incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java?view=diff&r1=151565&r2=151566
==============================================================================
--- incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java (original)
+++ incubator/directory/network/trunk/mina/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java Sun Feb 6 02:28:13 2005
@@ -3,6 +3,10 @@
*/
package org.apache.mina.protocol.codec;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+
import org.apache.asn1.codec.EncoderException;
import org.apache.asn1.codec.stateful.EncoderCallback;
import org.apache.asn1.codec.stateful.StatefulEncoder;
@@ -60,13 +64,45 @@
outBuf.flip();
encOut.write( outBuf );
}
+ else if( encoded instanceof Object[] )
+ {
+ Object[] bufArray = ( Object[] ) encoded;
+ for( int i = 0; i < bufArray.length; i ++ )
+ {
+ this.encodeOccurred( codec, bufArray[ i ] );
+ }
+ }
+ else if( encoded instanceof Iterator )
+ {
+ Iterator it = ( Iterator ) encoded;
+ while( it.hasNext() )
+ {
+ this.encodeOccurred( codec, it.next() );
+ }
+ }
+ else if( encoded instanceof Collection )
+ {
+ Iterator it = ( ( Collection ) encoded ).iterator();
+ while( it.hasNext() )
+ {
+ this.encodeOccurred( codec, it.next() );
+ }
+ }
+ else if( encoded instanceof Enumeration )
+ {
+ Enumeration e = ( Enumeration ) encoded;
+ while( e.hasMoreElements() )
+ {
+ this.encodeOccurred( codec, e.nextElement() );
+ }
+ }
else
{
throw new IllegalArgumentException(
- "Encoded result is not a ByteBuffer: "
- + encoded
- .getClass() );
+ "Encoded result is not a ByteBuffer: "
+ + encoded
+ .getClass() );
}
}
}
-}
\ No newline at end of file
+}