directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1771031 - in /directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util: Asn1StringUtils.java BitString.java Oid.java
Date Wed, 23 Nov 2016 19:23:27 GMT
Author: elecharny
Date: Wed Nov 23 19:23:27 2016
New Revision: 1771031

URL: http://svn.apache.org/viewvc?rev=1771031&view=rev
Log:
Fixed SonarLint issues

Modified:
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
    directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java?rev=1771031&r1=1771030&r2=1771031&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Asn1StringUtils.java
Wed Nov 23 19:23:27 2016
@@ -71,7 +71,7 @@ public final class Asn1StringUtils
             return "";
         }
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
 
         for ( byte b : buffer )
         {

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java?rev=1771031&r1=1771030&r2=1771031&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/BitString.java
Wed Nov 23 19:23:27 2016
@@ -64,7 +64,7 @@ public class BitString
         nbBits = length;
 
         // As we store values in bytes, we must divide the length by 8
-        nbBytes = ( length / 8 );
+        nbBytes = length / 8;
 
         if ( ( length % 8 ) != 0 )
         {

Modified: directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java?rev=1771031&r1=1771030&r2=1771031&view=diff
==============================================================================
--- directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
(original)
+++ directory/shared/trunk/asn1/api/src/main/java/org/apache/directory/api/asn1/util/Oid.java
Wed Nov 23 19:23:27 2016
@@ -249,7 +249,7 @@ public final class Oid
                             result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3]
& 0x78 ) >> 3 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2]
& 0x70 ) >> 4 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1]
& 0x60 ) >> 5 ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x40 ) >>
6 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >>
6 );
                             break;
                             
                         case 6 :
@@ -258,7 +258,7 @@ public final class Oid
                             result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3]
& 0x7C ) >> 2 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2]
& 0x78 ) >> 3 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1]
& 0x70 ) >> 4 ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x60 ) >>
5 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >>
5 );
                             break;
 
                         case 5 :
@@ -266,29 +266,29 @@ public final class Oid
                             result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3]
& 0x7E ) >> 1 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2]
& 0x7C ) >> 2 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1]
& 0x78 ) >> 3 ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x70 ) >>
4 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >>
4 );
                             break;
                             
                         case 4 :
                             result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3]
& 0x7F ) );
                             result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2]
& 0x7E ) >> 1 ) );
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1]
& 0x7C ) >> 2 ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x78 ) >>
3 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >>
3 );
                             break;
                             
                         case 3 :
                             result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2]
& 0x7F ) );
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1]
& 0x7E ) >> 1 ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x7C ) >>
2 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >>
2 );
                             break;
 
                         case 2 :
                             result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1]
& 0x7F ) );
-                            result[pos--] = ( byte ) ( ( oidBytes[0] & 0x7E ) >>
1 );
+                            result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >>
1 );
                             break;
                             
                         case 1 :
-                            result[pos--] = ( byte ) ( oidBytes[0] & 0x7F );
+                            result[pos] = ( byte ) ( oidBytes[0] & 0x7F );
                             break;
                             
                         default :
@@ -296,7 +296,7 @@ public final class Oid
                             break;
                     }
                     
-                    BigInteger bigInteger = null;
+                    BigInteger bigInteger;
                     
                     if ( ( result[0] & 0x80 ) == 0x80 )
                     {
@@ -352,7 +352,6 @@ public final class Oid
     
                     // normal processing
                     builder.append( '.' ).append( value );
-                    value = 0;
                 }
                 
                 valStart = i;
@@ -621,16 +620,17 @@ public final class Oid
     {
         char c = oid.charAt( pos );
         
-        switch ( c )
+        if ( c == '.' )
         {
-            case '.' :
-                // The first 2 arcs are single digit, we can collapse them in one byte.
-                buffer[0] = ( byte ) ( 80 + buffer[1] );
-                return OidFSAState.STATE_K;
-                
-            default :
-                // Expecting a digit here
-                throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a digit
is expected" ) );
+            // The first 2 arcs are single digit, we can collapse them in one byte.
+            buffer[0] = ( byte ) ( 80 + buffer[1] );
+            
+            return OidFSAState.STATE_K;
+        }
+        else
+        {
+            // Expecting a digit here
+            throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a digit is
expected" ) );
         }
     }
     
@@ -756,14 +756,14 @@ public final class Oid
     {
         char c = oid.charAt( pos );
         
-        switch ( c )
+        if ( c == '.' )
         {
-            case '.' :
                 return OidFSAState.STATE_K;
-                
-            default :
-                // Expecting a '.' here
-                throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a '.'
is expected" ) );
+        }
+        else
+        {
+            // Expecting a '.' here
+            throw new DecoderException( I18n.err( I18n.ERR_00033_INVALID_OID, "a '.' is expected"
) );
         }
     }
 
@@ -1078,7 +1078,7 @@ public final class Oid
         int startArc = 0;
         
         // The number of bytes in the resulting OID byte[]
-        int nbBytes = 0;
+        int nbBytes;
         
         for ( int i = 0; i < oidString.length(); i++ )
         {



Mime
View raw message