commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1457865 - in /commons/proper/fileupload/trunk: ./ src/checkstyle/ src/main/java/org/apache/commons/fileupload/util/mime/
Date Mon, 18 Mar 2013 17:05:48 GMT
Author: simonetripodi
Date: Mon Mar 18 17:05:47 2013
New Revision: 1457865

URL: http://svn.apache.org/r1457865
Log:
as discussed in ML, there are MagicNumbers which don't make sense to extract as constant for
the sake to make just Checkstyle happy, so MagicNumbers have been reverted - dropped also
the constants used only once - and added the related suppressions for interested files

Added:
    commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml   (with props)
Modified:
    commons/proper/fileupload/trunk/pom.xml
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java

Modified: commons/proper/fileupload/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/pom.xml?rev=1457865&r1=1457864&r2=1457865&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/pom.xml (original)
+++ commons/proper/fileupload/trunk/pom.xml Mon Mar 18 17:05:47 2013
@@ -259,6 +259,7 @@
         <version>2.10</version>
         <configuration>
           <configLocation>${basedir}/src/checkstyle/fileupload_checks.xml</configLocation>
+          <suppressionsLocation>${basedir}/src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
           <enableRulesSummary>false</enableRulesSummary>
           <headerFile>${basedir}/src/checkstyle/license-header.txt</headerFile>
         </configuration>

Added: commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml?rev=1457865&view=auto
==============================================================================
--- commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml (added)
+++ commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml Mon Mar 18
17:05:47 2013
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+     "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+     "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<suppressions>
+  <suppress checks="MagicNumber" files="(Base64|QuotedPrintable)Decoder.java" lines="0-9999"/>
+</suppressions>

Propchange: commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java?rev=1457865&r1=1457864&r2=1457865&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
Mon Mar 18 17:05:47 2013
@@ -25,26 +25,6 @@ import java.io.OutputStream;
 final class Base64Decoder {
 
     /**
-     * Bytes per undecoded block.
-     */
-    private static final int BYTES_PER_UNENCODED_BLOCK = 3;
-
-    /**
-     * 2 bits mask.
-     */
-    private static final int MASK_2BITS = 2;
-
-    /**
-     * 4 bits mask.
-     */
-    private static final int MASK_4BITS = 4;
-
-    /**
-     * 6 bits mask.
-     */
-    private static final int MASK_6BITS = 6;
-
-    /**
      * Set up the encoding table.
      */
     private static final byte[] ENCODING_TABLE = {
@@ -67,15 +47,10 @@ final class Base64Decoder {
     private static final byte PADDING = (byte) '=';
 
     /**
-     * The number of possible byte values; i.e. positives, negatives and zero.
-     */
-    private static final int DISTINCT_BYTE_VALUES = Byte.MAX_VALUE - Byte.MIN_VALUE + 1;
-
-    /**
      * Set up the decoding table; this is indexed by a byte converted to an int,
      * so must be at least as large as the number of different byte values.
      */
-    private static final byte[] DECODING_TABLE = new byte[DISTINCT_BYTE_VALUES];
+    private static final byte[] DECODING_TABLE = new byte[256];
 
     static {
         for (int i = 0; i < ENCODING_TABLE.length; i++) {
@@ -127,7 +102,7 @@ final class Base64Decoder {
         }
 
         int  i = off;
-        int  finish = end - MASK_4BITS;
+        int  finish = end - 4;
 
         while (i < finish) {
             while ((i < finish) && ignore((char) data[i])) {
@@ -154,40 +129,40 @@ final class Base64Decoder {
 
             b4 = DECODING_TABLE[data[i++]];
 
-            out.write((b1 << MASK_2BITS) | (b2 >> MASK_4BITS));
-            out.write((b2 << MASK_4BITS) | (b3 >> MASK_2BITS));
-            out.write((b3 << MASK_6BITS) | b4);
+            out.write((b1 << 2) | (b2 >> 4));
+            out.write((b2 << 4) | (b3 >> 2));
+            out.write((b3 << 6) | b4);
 
-            outLen += BYTES_PER_UNENCODED_BLOCK;
+            outLen += 3;
         }
 
-        if (data[end - MASK_2BITS] == PADDING) {
-            b1 = DECODING_TABLE[data[end - MASK_4BITS]];
-            b2 = DECODING_TABLE[data[end - BYTES_PER_UNENCODED_BLOCK]];
+        if (data[end - 2] == PADDING) {
+            b1 = DECODING_TABLE[data[end - 4]];
+            b2 = DECODING_TABLE[data[end - 3]];
 
-            out.write((b1 << MASK_2BITS) | (b2 >> MASK_4BITS));
+            out.write((b1 << 2) | (b2 >> 4));
 
             outLen += 1;
         } else if (data[end - 1] == PADDING) {
-            b1 = DECODING_TABLE[data[end - MASK_4BITS]];
-            b2 = DECODING_TABLE[data[end - BYTES_PER_UNENCODED_BLOCK]];
-            b3 = DECODING_TABLE[data[end - MASK_2BITS]];
+            b1 = DECODING_TABLE[data[end - 4]];
+            b2 = DECODING_TABLE[data[end - 3]];
+            b3 = DECODING_TABLE[data[end - 2]];
 
-            out.write((b1 << MASK_2BITS) | (b2 >> MASK_4BITS));
-            out.write((b2 << MASK_4BITS) | (b3 >> MASK_2BITS));
+            out.write((b1 << 2) | (b2 >> 4));
+            out.write((b2 << 4) | (b3 >> 2));
 
-            outLen += MASK_2BITS;
+            outLen += 2;
         } else {
-            b1 = DECODING_TABLE[data[end - MASK_4BITS]];
-            b2 = DECODING_TABLE[data[end - BYTES_PER_UNENCODED_BLOCK]];
-            b3 = DECODING_TABLE[data[end - MASK_2BITS]];
+            b1 = DECODING_TABLE[data[end - 4]];
+            b2 = DECODING_TABLE[data[end - 3]];
+            b3 = DECODING_TABLE[data[end - 2]];
             b4 = DECODING_TABLE[data[end - 1]];
 
-            out.write((b1 << MASK_2BITS) | (b2 >> MASK_4BITS));
-            out.write((b2 << MASK_4BITS) | (b3 >> MASK_2BITS));
-            out.write((b3 << MASK_6BITS) | b4);
+            out.write((b1 << 2) | (b2 >> 4));
+            out.write((b2 << 4) | (b3 >> 2));
+            out.write((b3 << 6) | b4);
 
-            outLen += BYTES_PER_UNENCODED_BLOCK;
+            outLen += 3;
         }
 
         return outLen;

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java?rev=1457865&r1=1457864&r2=1457865&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
Mon Mar 18 17:05:47 2013
@@ -33,20 +33,15 @@ final class QuotedPrintableDecoder {
     };
 
     /**
-     * The shift value required to create the upper nibble 
-     * from the first of 2 byte values converted from ascii hex. 
+     * The shift value required to create the upper nibble
+     * from the first of 2 byte values converted from ascii hex.
      */
     private static final int UPPER_NIBBLE_SHIFT = Byte.SIZE / 2;
 
     /**
-     * The decoding table size.
-     */
-    private static final int DECODING_TABLE_SIZE = 128;
-
-    /**
      * Set up the decoding table.
      */
-    private static final byte[] DECODING_TABLE = new byte[DECODING_TABLE_SIZE];
+    private static final byte[] DECODING_TABLE = new byte[128];
 
     static {
         // initialize the decoding table



Mime
View raw message