directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r368469 - in /directory/trunks/asn1/src/main/java/org/apache/asn1: ber/Asn1Decoder.java ber/grammar/AbstractGrammar.java util/BooleanDecoder.java
Date Thu, 12 Jan 2006 21:18:35 GMT
Author: elecharny
Date: Thu Jan 12 13:18:28 2006
New Revision: 368469

URL: http://svn.apache.org/viewcvs?rev=368469&view=rev
Log:
Updated the logs
- used the Message Format pattern
- deleted the DEBUG static

Modified:
    directory/trunks/asn1/src/main/java/org/apache/asn1/ber/Asn1Decoder.java
    directory/trunks/asn1/src/main/java/org/apache/asn1/ber/grammar/AbstractGrammar.java
    directory/trunks/asn1/src/main/java/org/apache/asn1/util/BooleanDecoder.java

Modified: directory/trunks/asn1/src/main/java/org/apache/asn1/ber/Asn1Decoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/asn1/src/main/java/org/apache/asn1/ber/Asn1Decoder.java?rev=368469&r1=368468&r2=368469&view=diff
==============================================================================
--- directory/trunks/asn1/src/main/java/org/apache/asn1/ber/Asn1Decoder.java (original)
+++ directory/trunks/asn1/src/main/java/org/apache/asn1/ber/Asn1Decoder.java Thu Jan 12 13:18:28
2006
@@ -47,9 +47,6 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( Asn1Decoder.class );
     
-    /** A speedup for logs */
-    private static boolean DEBUG;
-
     /** This flag is used to indicate that there are more bytes in the stream */
     private static final boolean MORE = true;
 
@@ -77,7 +74,6 @@
         indefiniteLengthAllowed = false;
         maxLengthLength         = 1;
         maxTagLength            = 1;
-        DEBUG = log.isDebugEnabled();
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -244,7 +240,7 @@
             current = current.getParent();
         }
         
-        log.debug("TLV Tree : " + sb.toString());
+        log.debug("TLV Tree : {}", sb.toString());
     }
     
     /**
@@ -293,10 +289,10 @@
         throws DecoderException
     {
 
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
             Tag tag = container.getCurrentTLV().getTag();
-            log.debug( tag.toString() + " has been decoded" );
+            log.debug( "Tag {} has been decoded", tag.toString() );
         }
         
         // Create a link between the current TLV with its parent
@@ -407,9 +403,9 @@
 
                 byte octet = stream.get();
 
-                if ( DEBUG )
+                if ( log.isDebugEnabled() )
                 {
-                    log.debug( "  current byte : " + Asn1StringUtils.dumpByte( octet ) );
+                    log.debug( "  current byte : {}", Asn1StringUtils.dumpByte( octet ) );
                 }
 
                 length.incCurrentLength();
@@ -477,21 +473,21 @@
         // exceeded by the current TLV.
         TLV parentTLV = container.getParentTLV();
         
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
-            log.debug(getParentLength(parentTLV));
+            log.debug( "Parent length : {}", new Integer( getParentLength( parentTLV ) )
);
         }
         
         if (parentTLV == null) 
         {
             // This is the first TLV, so we can't check anything. We will
             // just store this TLV as the root of the PDU
-            tlv.setExpectedLength(length.getLength());
-            container.setParentTLV(tlv);
+            tlv.setExpectedLength( length.getLength() );
+            container.setParentTLV( tlv );
             
-            if ( DEBUG )
+            if ( log.isDebugEnabled() )
             {
-                log.debug("Root TLV[" + tlv.getLength().getLength() + "]");
+                log.debug( "Root TLV[{}]", new Integer( tlv.getLength().getLength() ) );
             }
         }
         else
@@ -505,7 +501,7 @@
             {
                 // The expected length is lower than the Value length of the
                 // current TLV. This is an error...
-                log.error("tlv[" + expectedLength + ", " + currentLength + "]");
+                log.error("tlv[{}, {}]", new Integer( expectedLength ), new Integer( currentLength
) );
                 throw new DecoderException("The current Value length is above the expected
length");
             }
             
@@ -593,9 +589,9 @@
             
         }
 
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
-            log.debug( length.toString() + " has been decoded" );
+            log.debug( "Length {} has been decoded", length.toString() );
         }
 
         if ( length.getLength() == 0 )
@@ -722,7 +718,7 @@
     private boolean treatTLVDoneState( ByteBuffer stream, IAsn1Container container )
         throws DecoderException
     {
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
             dumpTLVTree(container);
         }
@@ -821,29 +817,26 @@
 
         boolean hasRemaining = stream.hasRemaining();
 
-        if ( DEBUG )
-        {
-            log.debug( ">>>==========================================" );
-            log.debug( "--> Decoding a PDU" );
-            log.debug( ">>>------------------------------------------" );
-        }
+        log.debug( ">>>==========================================" );
+        log.debug( "--> Decoding a PDU" );
+        log.debug( ">>>------------------------------------------" );
 
         while ( hasRemaining )
         {
 
-            if ( DEBUG )
+            if ( log.isDebugEnabled() )
             {
-                log.debug( "--- State = " + stateToString( container.getState() ) + " ---"
);
+                log.debug( "--- State = {} ---", stateToString( container.getState() ) );
 
                 if (stream.hasRemaining())
                 {
                     byte octet = stream.get(stream.position());
 
-                    log.debug( "  current byte : " + Asn1StringUtils.dumpByte( octet ) );
+                    log.debug( "  current byte : {}", Asn1StringUtils.dumpByte( octet ) );
                 }
                 else
                 {
-                    log.debug( "  no more byte to decode in the stream");
+                    log.debug( "  no more byte to decode in the stream" );
                 }
             }
 
@@ -908,10 +901,7 @@
                 case TLVStateEnum.PDU_DECODED :
                     // We have to deal with the case where there are
                     // more bytes in the buffer, but the PDU has been decoded.
-                    if ( log.isWarnEnabled() )
-                    {
-                        log.warn("The PDU has been fully decoded but there are still bytes
in the buffer.");
-                    }
+                    log.warn( "The PDU has been fully decoded but there are still bytes in
the buffer." );
                     
                     hasRemaining = false;
                     
@@ -919,17 +909,17 @@
             }
         }
 
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
             log.debug( "<<<------------------------------------------" );
             
             if ( container.getState() == TLVStateEnum.PDU_DECODED )
             {
-                log.debug( "<-- Stop decoding : " + container.getCurrentTLV().toString()
);
+                log.debug( "<-- Stop decoding : {}", container.getCurrentTLV().toString()
);
             }
             else
             {
-                log.debug( "<-- End decoding : " + container.getCurrentTLV().toString()
);
+                log.debug( "<-- End decoding : {}", container.getCurrentTLV().toString()
);
             }
             
             log.debug( "<<<==========================================" );
@@ -1019,3 +1009,4 @@
     }
 
 } // end class TLVTagDecoder
+

Modified: directory/trunks/asn1/src/main/java/org/apache/asn1/ber/grammar/AbstractGrammar.java
URL: http://svn.apache.org/viewcvs/directory/trunks/asn1/src/main/java/org/apache/asn1/ber/grammar/AbstractGrammar.java?rev=368469&r1=368468&r2=368469&view=diff
==============================================================================
--- directory/trunks/asn1/src/main/java/org/apache/asn1/ber/grammar/AbstractGrammar.java (original)
+++ directory/trunks/asn1/src/main/java/org/apache/asn1/ber/grammar/AbstractGrammar.java Thu
Jan 12 13:18:28 2006
@@ -40,9 +40,6 @@
     /** The logger */
     private static final Logger log = LoggerFactory.getLogger( AbstractGrammar.class );
 
-    /** A speedup for logs */
-    private static boolean DEBUG;
-
     //~ Instance fields ----------------------------------------------------------------------------
 
     /** Table of transitions. It's a two dimension array, the first dimension
@@ -57,7 +54,6 @@
     
     public AbstractGrammar()
     {
-    	DEBUG = log.isDebugEnabled();
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -100,7 +96,7 @@
 
         int tlvLength      = tlv.getSize();
 
-        if ( DEBUG )
+        if ( log.isDebugEnabled() )
         {
             log.debug(
                 "Expected Length = " + ( ( Asn1Object ) object ).getExpectedLength() +
@@ -184,7 +180,7 @@
                 }
             }
 
-            if ( DEBUG )
+            if ( log.isDebugEnabled() )
             {
                 log.debug( transition.toString( container.getCurrentGrammarType(),
                         currentGrammar.getStatesEnum() ) );
@@ -196,12 +192,12 @@
                     ( nextState != IStates.END_STATE ) )
             {
 
-                if ( DEBUG )
+                if ( log.isDebugEnabled() )
                 {
                     log.debug(
-                        "Switching from grammar " +
-                        container.getStates().getGrammarName( currentGrammar ) +
-                        " to grammar " + container.getStates().getGrammarName( ( nextState
>> 8 ) - 1 ) );
+                        "Switching from grammar {} to grammar {}",
+                        container.getStates().getGrammarName( currentGrammar ),
+                        container.getStates().getGrammarName( ( nextState >> 8 ) -
1 ) );
                 }
 
                 // We have a grammar switch, so we change the current state to the initial
@@ -246,3 +242,4 @@
         this.statesEnum = statesEnum;
     }
 }
+

Modified: directory/trunks/asn1/src/main/java/org/apache/asn1/util/BooleanDecoder.java
URL: http://svn.apache.org/viewcvs/directory/trunks/asn1/src/main/java/org/apache/asn1/util/BooleanDecoder.java?rev=368469&r1=368468&r2=368469&view=diff
==============================================================================
--- directory/trunks/asn1/src/main/java/org/apache/asn1/util/BooleanDecoder.java (original)
+++ directory/trunks/asn1/src/main/java/org/apache/asn1/util/BooleanDecoder.java Thu Jan 12
13:18:28 2006
@@ -61,3 +61,4 @@
         return bytes[0] != 0;
     }
 }
+



Mime
View raw message