directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r161404 - directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
Date Fri, 15 Apr 2005 05:47:30 GMT
Author: elecharny
Date: Thu Apr 14 22:47:29 2005
New Revision: 161404

URL: http://svn.apache.org/viewcvs?view=rev&rev=161404
Log:
Cleanded the debug code, and modified methods that don't need a stream parameter

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java?view=diff&r1=161403&r2=161404
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/Asn1Decoder.java Thu
Apr 14 22:47:29 2005
@@ -127,11 +127,6 @@
 
             byte octet = stream.get();
 
-            if ( DEBUG )
-            {
-                log.debug( "  current byte : " + StringUtils.dumpByte( octet ) );
-            }
-
             try
             {
 
@@ -225,11 +220,6 @@
             Tag  tag    = container.getCurrentTLV().getTag();
             byte octect = stream.get();
 
-            if ( DEBUG )
-            {
-                log.debug( "  current byte : " + StringUtils.dumpByte( octect ) );
-            }
-
             if ( tag.getSize() >= Tag.MAX_TAG_BYTES )
             {
                 container.setState( TLVStateEnum.TAG_STATE_OVERFLOW );
@@ -264,16 +254,12 @@
      * is a debug action. We will log the information that the Tag has been
      * decoded.
      *  
-     * @param stream The ByteBuffer containing the PDU to decode
      * @param container The container that stores the current state,
      * the result and other informations.
      * 
-     * @return <code>true</code> if there are more bytes to read, <code>false

-     * </code> otherwise
-     * 
      * @throws DecoderException Thrown if anything went wrong
      */
-    private boolean treatTagEndState( ByteBuffer stream, IAsn1Container container )
+    private void treatTagEndState( IAsn1Container container )
         throws DecoderException
     {
 
@@ -290,8 +276,6 @@
 
         // Switch to the next state, which is the Length decoding
         container.setState( TLVStateEnum.LENGTH_STATE_START );
-
-        return MORE;
     }
 
     /**
@@ -316,11 +300,6 @@
 
             byte octet = stream.get();
 
-            if ( DEBUG )
-            {
-                log.debug( "  current byte : " + StringUtils.dumpByte( octet ) );
-            }
-
             Length length = container.getCurrentTLV().getLength();
 
             if ( ( octet & Length.LENGTH_LONG_FORM ) == 0 )
@@ -428,16 +407,12 @@
      * The Length is fully decoded. We have to call an action to check the
      * size.
      *
-     * @param stream The ByteBuffer containing the PDU to decode
      * @param container The container that stores the current state,
      * the result and other informations.
      * 
-     * @return <code>true</code> if there are more bytes to read, <code>false

-     * </code> otherwise
-     * 
      * @throws DecoderException Thrown if anything went wrong
      */
-    private boolean treatLengthEndState( ByteBuffer stream, IAsn1Container container )
+    private void treatLengthEndState( IAsn1Container container )
         throws DecoderException
     {
 
@@ -463,8 +438,6 @@
 
         // Execute the action to check if the length is OK
         container.getGrammar().executeAction( container );
-
-        return MORE;
     }
 
     /**
@@ -674,6 +647,17 @@
             if ( DEBUG )
             {
                 log.debug( "--- State = " + stateToString( container.getState() ) + " ---"
);
+
+                if (stream.hasRemaining())
+                {
+                    byte octet = stream.get(stream.position());
+
+                    log.debug( "  current byte : " + StringUtils.dumpByte( octet ) );
+                }
+                else
+                {
+                    log.debug( "  no more byte to decode in the stream");
+                }
             }
 
             switch ( container.getState() )
@@ -690,7 +674,7 @@
                     break;
 
                 case TLVStateEnum.TAG_STATE_END :
-                    hasRemaining = treatTagEndState( stream, container );
+                    treatTagEndState( container );
 
                     break;
 
@@ -709,7 +693,7 @@
                     break;
 
                 case TLVStateEnum.LENGTH_STATE_END :
-                    hasRemaining = treatLengthEndState( stream, container );
+                    treatLengthEndState( container );
 
                     break;
 
@@ -724,13 +708,14 @@
                     break;
 
                 case TLVStateEnum.VALUE_STATE_END :
+                	hasRemaining = stream.hasRemaining();
 
                     // Nothing to do. We will never reach this state
                     break;
 
                 case TLVStateEnum.TLV_STATE_DONE :
                     hasRemaining = treatTLVDoneState( stream, container );
-
+                	hasRemaining = stream.hasRemaining();
                     break;
             }
         }
@@ -739,8 +724,6 @@
         {
             log.debug( "<--- End decoding : " + container.getCurrentTLV().toString() );
         }
-
-        return;
     } // end method decode
 
     /**
@@ -834,14 +817,7 @@
      */
     public PoolObject allocate( int pool ) throws PoolException
     {
-    	if (isPooled)
-    	{
-       		return poolMgr.allocate( pool );
-    	}
-    	else
-    	{
-    		return PoolEnum.allocate( pool );
-    	}
+   		return isPooled ? poolMgr.allocate( pool ) : PoolEnum.allocate( pool );
     }
 
     /**



Mime
View raw message