directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r267370 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
Date Sat, 03 Sep 2005 01:17:48 GMT
Author: elecharny
Date: Fri Sep  2 18:17:44 2005
New Revision: 267370

URL: http://svn.apache.org/viewcvs?rev=267370&view=rev
Log:
- Added the missing code to fully implement the decoder
- Added some logs
- Added some doco

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

Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java?rev=267370&r1=267369&r2=267370&view=diff
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
(original)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
Fri Sep  2 18:17:44 2005
@@ -3,27 +3,34 @@
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 
-import org.apache.asn1.ber.digester.BERDigester;
 import org.apache.asn1.codec.DecoderException;
 import org.apache.asn1.codec.stateful.DecoderCallback;
 import org.apache.asn1.codec.stateful.DecoderMonitor;
-import org.apache.asn1.codec.stateful.StatefulDecoder;
 import org.apache.asn1new.ber.Asn1Decoder;
-import org.apache.asn1new.ber.containers.IAsn1Container;
 import org.apache.asn1new.ber.tlv.TLVStateEnum;
 import org.apache.asn1new.ldap.codec.LdapDecoder;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
-import org.apache.ldap.common.berlib.asn1.decoder.LdapDigesterFactory;
-import org.apache.ldap.common.message.Message;
+import org.apache.asn1new.util.StringUtils;
 import org.apache.ldap.common.message.spi.Provider;
 import org.apache.ldap.common.message.spi.ProviderDecoder;
 import org.apache.ldap.common.message.spi.ProviderException;
+import org.apache.log4j.Logger;
 
 public class TwixDecoder implements ProviderDecoder {
+    /** The logger */
+    private static final Logger log = Logger.getLogger( TwixDecoder.class );
+
+    /** The associated Provider */
     private final Provider provider;
     
+    /** The message container for this instance */ 
     private final LdapMessageContainer ldapMessageContainer;
+    
+    /** The Ldap BDER decoder instance */
     private final Asn1Decoder ldapDecoder;
+    
+    /** The callback to call when the decoding is done */
+    private DecoderCallback decoderCallback;
 
     /**
      * Creates an instance of a Twix Decoder implementation.
@@ -37,6 +44,9 @@
         ldapDecoder = new LdapDecoder();
     }
 
+    /**
+     * 
+     */
     public void decode( Object encoded ) throws DecoderException
     {
         ByteBuffer buf = null;
@@ -55,12 +65,35 @@
                     "ByteBuffer argument but got a " + encoded.getClass() );
         }
 
+    	if (log.isDebugEnabled())
+    	{
+    		log.debug( "Decoding the PDU : " );
+    		
+    		if (buf.hasArray()) 
+    		{
+    			log.debug( StringUtils.dumpBytes( buf.array() ) );
+    		}
+    		else
+    		{
+    			byte[] array = new byte[buf.capacity()];
+    			int i = 0;
+    			
+    			while ( buf.hasRemaining() )
+    			{
+    				array[i++] = buf.get();
+    			}
+    			
+    			buf.flip();
+    			log.debug( StringUtils.dumpBytes( array ) );
+    		}
+    	}
+    	
        	ldapDecoder.decode( buf, ldapMessageContainer );
        	
        	if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
        	{
-       		// Send the result to the callback.
-       		// TO BE DONE
+       		decoderCallback.decodeOccurred( null, ldapMessageContainer.getLdapMessage() );
+       		ldapMessageContainer.clean();
        	}
     }
     
@@ -170,11 +203,18 @@
         return provider ;
     }
 
+    /**
+     * 
+     */
     public void setDecoderMonitor( DecoderMonitor monitor )
     {
     }
 
+    /**
+     * 
+     */
     public void setCallback( DecoderCallback cb )
     {
+    	decoderCallback = cb;
     }
 }



Mime
View raw message