tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1593536 - in /tomcat/trunk: java/org/apache/tomcat/util/codec/binary/Base64.java java/org/apache/tomcat/util/codec/binary/BaseNCodec.java webapps/docs/changelog.xml
Date Fri, 09 May 2014 12:57:08 GMT
Author: markt
Date: Fri May  9 12:57:08 2014
New Revision: 1593536

URL: http://svn.apache.org/r1593536
Log:
Update package renamed Apache Commons Codec to r1586336 to pick up some Javadoc fixes and
some code clean up.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java
    tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java?rev=1593536&r1=1593535&r2=1593536&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/codec/binary/Base64.java Fri May  9 12:57:08
2014
@@ -27,13 +27,13 @@ import java.math.BigInteger;
  * </p>
  * <p>
  * The class can be parameterized in the following manner with various constructors:
+ * </p>
  * <ul>
  * <li>URL-safe mode: Default off.</li>
  * <li>Line length: Default 76. Line length that aren't multiples of 4 will still essentially
end up being multiples of
  * 4 in the encoded data.
  * <li>Line separator: Default is CRLF ("\r\n")</li>
  * </ul>
- * </p>
  * <p>
  * Since this class operates directly on byte streams, and not character streams, it is hard-coded
to only
  * encode/decode character encodings which are compatible with the lower 127 ASCII chart
(ISO-8859-1, Windows-1252,
@@ -138,7 +138,7 @@ public class Base64 extends BaseNCodec {
     private final byte[] decodeTable = DECODE_TABLE;
 
     /**
-     * Line separator for encoding. Not used when decoding. Only used if lineLength >
0.
+     * Line separator for encoding. Not used when decoding. Only used if lineLength &gt;
0.
      */
     private final byte[] lineSeparator;
 
@@ -202,7 +202,7 @@ public class Base64 extends BaseNCodec {
      *
      * @param lineLength
      *            Each line of encoded data will be at most of the given length (rounded
down to nearest multiple of
-     *            4). If lineLength <= 0, then the output will not be divided into lines
(chunks). Ignored when
+     *            4). If lineLength &lt;= 0, then the output will not be divided into
lines (chunks). Ignored when
      *            decoding.
      * @since 1.4
      */
@@ -225,7 +225,7 @@ public class Base64 extends BaseNCodec {
      *
      * @param lineLength
      *            Each line of encoded data will be at most of the given length (rounded
down to nearest multiple of
-     *            4). If lineLength <= 0, then the output will not be divided into lines
(chunks). Ignored when
+     *            4). If lineLength &lt;= 0, then the output will not be divided into
lines (chunks). Ignored when
      *            decoding.
      * @param lineSeparator
      *            Each line of encoded data will end with this sequence of bytes.
@@ -252,7 +252,7 @@ public class Base64 extends BaseNCodec {
      *
      * @param lineLength
      *            Each line of encoded data will be at most of the given length (rounded
down to nearest multiple of
-     *            4). If lineLength <= 0, then the output will not be divided into lines
(chunks). Ignored when
+     *            4). If lineLength &lt;= 0, then the output will not be divided into
lines (chunks). Ignored when
      *            decoding.
      * @param lineSeparator
      *            Each line of encoded data will end with this sequence of bytes.
@@ -346,8 +346,8 @@ public class Base64 extends BaseNCodec {
                     buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4)
& MASK_6BITS];
                     // URL-SAFE skips the padding to further reduce size.
                     if (encodeTable == STANDARD_ENCODE_TABLE) {
-                        buffer[context.pos++] = PAD;
-                        buffer[context.pos++] = PAD;
+                        buffer[context.pos++] = pad;
+                        buffer[context.pos++] = pad;
                     }
                     break;
 
@@ -357,7 +357,7 @@ public class Base64 extends BaseNCodec {
                     buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2)
& MASK_6BITS];
                     // URL-SAFE skips the padding to further reduce size.
                     if (encodeTable == STANDARD_ENCODE_TABLE) {
-                        buffer[context.pos++] = PAD;
+                        buffer[context.pos++] = pad;
                     }
                     break;
                 default:
@@ -430,7 +430,7 @@ public class Base64 extends BaseNCodec {
         for (int i = 0; i < inAvail; i++) {
             final byte[] buffer = ensureBufferSize(decodeSize, context);
             final byte b = in[inPos++];
-            if (b == PAD) {
+            if (b == pad) {
                 // We're done.
                 context.eof = true;
                 break;
@@ -479,21 +479,6 @@ public class Base64 extends BaseNCodec {
     }
 
     /**
-     * Tests a given byte array to see if it contains only valid characters within the Base64
alphabet. Currently the
-     * method treats whitespace as valid.
-     *
-     * @param arrayOctet
-     *            byte array to test
-     * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if
the byte array is empty;
-     *         {@code false}, otherwise
-     * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0.
-     */
-    @Deprecated
-    public static boolean isArrayByteBase64(final byte[] arrayOctet) {
-        return isBase64(arrayOctet);
-    }
-
-    /**
      * Returns whether or not the <code>octet</code> is in the base 64 alphabet.
      *
      * @param octet

Modified: tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java?rev=1593536&r1=1593535&r2=1593536&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java Fri May  9 12:57:08
2014
@@ -75,7 +75,7 @@ public abstract class BaseNCodec impleme
 
         /**
          * Variable tracks how many characters have been written to the current line. Only
used when encoding. We use
-         * it to make sure each encoded line never goes beyond lineLength (if lineLength
> 0).
+         * it to make sure each encoded line never goes beyond lineLength (if lineLength
&gt; 0).
          */
         int currentLinePos;
 
@@ -151,7 +151,7 @@ public abstract class BaseNCodec impleme
      */
     protected static final byte PAD_DEFAULT = '='; // Allow static access to default
 
-    protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to
vary later
+    protected final byte pad; // instance variable just in case it needs to vary later
 
     /** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for
Base32 */
     private final int unencodedBlockSize;
@@ -167,7 +167,7 @@ public abstract class BaseNCodec impleme
     protected final int lineLength;
 
     /**
-     * Size of chunk separator. Not used unless {@link #lineLength} > 0.
+     * Size of chunk separator. Not used unless {@link #lineLength} &gt; 0.
      */
     private final int chunkSeparatorLength;
 
@@ -181,11 +181,27 @@ public abstract class BaseNCodec impleme
      */
     protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize,
                          final int lineLength, final int chunkSeparatorLength) {
+        this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT);
+    }
+
+    /**
+     * Note <code>lineLength</code> is rounded down to the nearest multiple of
{@link #encodedBlockSize}
+     * If <code>chunkSeparatorLength</code> is zero, then chunking is disabled.
+     * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3)
+     * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4)
+     * @param lineLength if &gt; 0, use chunking with a length <code>lineLength</code>
+     * @param chunkSeparatorLength the chunk separator length, if relevant
+     * @param pad byte used as padding byte.
+     */
+    protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize,
+                         final int lineLength, final int chunkSeparatorLength, final byte
pad) {
         this.unencodedBlockSize = unencodedBlockSize;
         this.encodedBlockSize = encodedBlockSize;
         final boolean useChunking = lineLength > 0 && chunkSeparatorLength >
0;
         this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize
: 0;
         this.chunkSeparatorLength = chunkSeparatorLength;
+
+        this.pad = pad;
     }
 
     /**
@@ -442,7 +458,7 @@ public abstract class BaseNCodec impleme
     public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) {
         for (int i = 0; i < arrayOctet.length; i++) {
             if (!isInAlphabet(arrayOctet[i]) &&
-                    (!allowWSPad || (arrayOctet[i] != PAD) && !isWhiteSpace(arrayOctet[i])))
{
+                    (!allowWSPad || (arrayOctet[i] != pad) && !isWhiteSpace(arrayOctet[i])))
{
                 return false;
             }
         }
@@ -476,7 +492,7 @@ public abstract class BaseNCodec impleme
             return false;
         }
         for (final byte element : arrayOctet) {
-            if (PAD == element || isInAlphabet(element)) {
+            if (pad == element || isInAlphabet(element)) {
                 return true;
             }
         }
@@ -489,7 +505,7 @@ public abstract class BaseNCodec impleme
      * @param pArray byte[] array which will later be encoded
      *
      * @return amount of space needed to encoded the supplied array.
-     * Returns a long since a max-len array will require > Integer.MAX_VALUE
+     * Returns a long since a max-len array will require &gt; Integer.MAX_VALUE
      */
     public long getEncodedLength(final byte[] pArray) {
         // Calculate non-chunked size - rounded up to allow for padding

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1593536&r1=1593535&r2=1593536&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri May  9 12:57:08 2014
@@ -364,6 +364,10 @@
         some small improvements (e.g. better <code>null</code> protection) and
         some code clean up. (markt)
       </update>
+      <update>
+        Update package renamed Apache Commons Codec to r1586336 to pick up some
+        Javadoc fixes and some code clean up. (markt)
+      </update>
     </changelog>
   </subsection>
 </section>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message