minor Base64Decoder refactoring to reflect QuotedPrintableDecoder structure

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1456843 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
index 0adccba..c4274fc 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
@@ -24,7 +24,7 @@
  */
 final class Base64Decoder {
 
-    private final byte[] encodingTable = {
+    private static final byte[] ENCODING_TABLE = {
         (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G',
         (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
         (byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',
@@ -39,24 +39,24 @@
         (byte) '+', (byte) '/'
     };
 
-    private byte padding = (byte) '=';
+    private static final byte PADDING = (byte) '=';
 
     /*
      * set up the decoding table.
      */
-    private final byte[] decodingTable = new byte[256];
+    private static final byte[] DECODING_TABLE = new byte[256];
 
-    protected void initialiseDecodingTable() {
-        for (int i = 0; i < encodingTable.length; i++) {
-            decodingTable[encodingTable[i]] = (byte) i;
+    static {
+        for (int i = 0; i < ENCODING_TABLE.length; i++) {
+            DECODING_TABLE[ENCODING_TABLE[i]] = (byte) i;
         }
     }
 
-    public Base64Decoder() {
-        initialiseDecodingTable();
+    private Base64Decoder() {
+        // do nothing
     }
 
-    private boolean ignore(
+    private static boolean ignore(
         char    c) {
         return (c == '\n' || c == '\r' || c == '\t' || c == ' ');
     }
@@ -67,7 +67,7 @@
      *
      * @return the number of bytes produced.
      */
-    public int decode(
+    public static int decode(
         byte[]                data,
         int                    off,
         int                    length,
@@ -94,25 +94,25 @@
                 i++;
             }
 
-            b1 = decodingTable[data[i++]];
+            b1 = DECODING_TABLE[data[i++]];
 
             while ((i < finish) && ignore((char) data[i])) {
                 i++;
             }
 
-            b2 = decodingTable[data[i++]];
+            b2 = DECODING_TABLE[data[i++]];
 
             while ((i < finish) && ignore((char) data[i])) {
                 i++;
             }
 
-            b3 = decodingTable[data[i++]];
+            b3 = DECODING_TABLE[data[i++]];
 
             while ((i < finish) && ignore((char) data[i])) {
                 i++;
             }
 
-            b4 = decodingTable[data[i++]];
+            b4 = DECODING_TABLE[data[i++]];
 
             out.write((b1 << 2) | (b2 >> 4));
             out.write((b2 << 4) | (b3 >> 2));
@@ -121,27 +121,27 @@
             outLen += 3;
         }
 
-        if (data[end - 2] == padding) {
-            b1 = decodingTable[data[end - 4]];
-            b2 = decodingTable[data[end - 3]];
+        if (data[end - 2] == PADDING) {
+            b1 = DECODING_TABLE[data[end - 4]];
+            b2 = DECODING_TABLE[data[end - 3]];
 
             out.write((b1 << 2) | (b2 >> 4));
 
             outLen += 1;
-        } else if (data[end - 1] == padding) {
-            b1 = decodingTable[data[end - 4]];
-            b2 = decodingTable[data[end - 3]];
-            b3 = decodingTable[data[end - 2]];
+        } else if (data[end - 1] == PADDING) {
+            b1 = DECODING_TABLE[data[end - 4]];
+            b2 = DECODING_TABLE[data[end - 3]];
+            b3 = DECODING_TABLE[data[end - 2]];
 
             out.write((b1 << 2) | (b2 >> 4));
             out.write((b2 << 4) | (b3 >> 2));
 
             outLen += 2;
         } else {
-            b1 = decodingTable[data[end - 4]];
-            b2 = decodingTable[data[end - 3]];
-            b3 = decodingTable[data[end - 2]];
-            b4 = decodingTable[data[end - 1]];
+            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 << 2) | (b2 >> 4));
             out.write((b2 << 4) | (b3 >> 2));
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
index 4d67044..ab30c5b 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
@@ -40,11 +40,6 @@
      */
     private static final Map<String, String> MIME2JAVA = new HashMap<String, String>();
 
-    /**
-     * The Base64 decoder.
-     */
-    private static final Base64Decoder BASE64_DECODER = new Base64Decoder();
-
     static {
         MIME2JAVA.put("iso-2022-cn", "ISO2022CN");
         MIME2JAVA.put("iso-2022-kr", "ISO2022KR");
@@ -223,7 +218,7 @@
 
             // Base64 encoded?
             if (encoding.equals("B")) {
-                BASE64_DECODER.decode(encodedData, 0, encodedData.length, out);
+                Base64Decoder.decode(encodedData, 0, encodedData.length, out);
             } else if (encoding.equals("Q")) { // maybe quoted printable.
                 QuotedPrintableDecoder.decodeWord(encodedData, 0, encodedData.length, out);
             } else {