This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git
The following commit(s) were added to refs/heads/master by this push: new 729bdc89 Rename private constants 729bdc89 is described below commit 729bdc893d34044bca31466848b5b79be3ffd93a Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Mar 22 15:43:34 2025 -0400 Rename private constants --- .../org/apache/commons/codec/binary/Base16.java | 6 +- .../org/apache/commons/codec/binary/Base32.java | 70 +++++++++++----------- .../org/apache/commons/codec/binary/Base64.java | 28 ++++----- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/main/java/org/apache/commons/codec/binary/Base16.java b/src/main/java/org/apache/commons/codec/binary/Base16.java index d1920a10..f2379081 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base16.java +++ b/src/main/java/org/apache/commons/codec/binary/Base16.java @@ -92,7 +92,7 @@ public class Base16 extends BaseNCodec { private static final byte[] LOWER_CASE_ENCODE_TABLE = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; /** Mask used to extract 4 bits, used when decoding character. */ - private static final int MASK_4BITS = 0x0f; + private static final int MASK_4_BITS = 0x0f; /** * Decode table to use. @@ -215,8 +215,8 @@ public class Base16 extends BaseNCodec { final int end = offset + length; for (int i = offset; i < end; i++) { final int value = data[i]; - final int high = value >> BITS_PER_ENCODED_BYTE & MASK_4BITS; - final int low = value & MASK_4BITS; + final int high = value >> BITS_PER_ENCODED_BYTE & MASK_4_BITS; + final int low = value & MASK_4_BITS; buffer[context.pos++] = encodeTable[high]; buffer[context.pos++] = encodeTable[low]; } diff --git a/src/main/java/org/apache/commons/codec/binary/Base32.java b/src/main/java/org/apache/commons/codec/binary/Base32.java index 258c53b8..5ebecbcb 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base32.java +++ b/src/main/java/org/apache/commons/codec/binary/Base32.java @@ -175,19 +175,19 @@ public class Base32 extends BaseNCodec { // @formatter:on /** Mask used to extract 5 bits, used when encoding Base32 bytes */ - private static final int MASK_5BITS = 0x1f; + private static final int MASK_5_BITS = 0x1f; /** Mask used to extract 4 bits, used when decoding final trailing character. */ - private static final long MASK_4BITS = 0x0fL; + private static final long MASK_4_BITS = 0x0fL; /** Mask used to extract 3 bits, used when decoding final trailing character. */ - private static final long MASK_3BITS = 0x07L; + private static final long MASK_3_BITS = 0x07L; /** Mask used to extract 2 bits, used when decoding final trailing character. */ - private static final long MASK_2BITS = 0x03L; + private static final long MASK_2_BITS = 0x03L; /** Mask used to extract 1 bits, used when decoding final trailing character. */ - private static final long MASK_1BITS = 0x01L; + private static final long MASK_1_BITS = 0x01L; // The static final fields above are used for the original static byte[] methods on Base32. // The private member fields below are used with the new streaming approach, which requires @@ -484,7 +484,7 @@ public class Base32 extends BaseNCodec { validateTrailingCharacters(); // falls-through case 2: // 10 bits, drop 2 and output one byte - validateCharacter(MASK_2BITS, context); + validateCharacter(MASK_2_BITS, context); buffer[context.pos++] = (byte) (context.lbitWorkArea >> 2 & MASK_8BITS); break; case 3: // 15 bits, drop 7 and output 1 byte, or raise an exception @@ -493,13 +493,13 @@ public class Base32 extends BaseNCodec { buffer[context.pos++] = (byte) (context.lbitWorkArea >> 7 & MASK_8BITS); break; case 4: // 20 bits = 2*8 + 4 - validateCharacter(MASK_4BITS, context); + validateCharacter(MASK_4_BITS, context); context.lbitWorkArea = context.lbitWorkArea >> 4; // drop 4 bits buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS); buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS); break; case 5: // 25 bits = 3*8 + 1 - validateCharacter(MASK_1BITS, context); + validateCharacter(MASK_1_BITS, context); context.lbitWorkArea = context.lbitWorkArea >> 1; buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS); buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS); @@ -514,7 +514,7 @@ public class Base32 extends BaseNCodec { buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS); break; case 7: // 35 bits = 4*8 +3 - validateCharacter(MASK_3BITS, context); + validateCharacter(MASK_3_BITS, context); context.lbitWorkArea = context.lbitWorkArea >> 3; buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS); buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS); @@ -558,8 +558,8 @@ public class Base32 extends BaseNCodec { case 0: break; case 1: // Only 1 octet; take top 5 bits then remainder - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5BITS]; // 8-1*5 = 3 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5BITS]; // 5-3=2 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5_BITS]; // 8-1*5 = 3 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5_BITS]; // 5-3=2 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; @@ -568,33 +568,33 @@ public class Base32 extends BaseNCodec { buffer[context.pos++] = pad; break; case 2: // 2 octets = 16 bits to use - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5BITS]; // 16-1*5 = 11 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5BITS]; // 16-2*5 = 6 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5BITS]; // 16-3*5 = 1 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5BITS]; // 5-1 = 4 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5_BITS]; // 16-1*5 = 11 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5_BITS]; // 16-2*5 = 6 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5_BITS]; // 16-3*5 = 1 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5_BITS]; // 5-1 = 4 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; break; case 3: // 3 octets = 24 bits to use - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5BITS]; // 24-1*5 = 19 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5BITS]; // 24-2*5 = 14 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5BITS]; // 24-3*5 = 9 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5BITS]; // 24-4*5 = 4 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5BITS]; // 5-4 = 1 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5_BITS]; // 24-1*5 = 19 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5_BITS]; // 24-2*5 = 14 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5_BITS]; // 24-3*5 = 9 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5_BITS]; // 24-4*5 = 4 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5_BITS]; // 5-4 = 1 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; break; case 4: // 4 octets = 32 bits to use - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5BITS]; // 32-1*5 = 27 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5BITS]; // 32-2*5 = 22 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5BITS]; // 32-3*5 = 17 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5BITS]; // 32-4*5 = 12 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5BITS]; // 32-5*5 = 7 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5BITS]; // 32-6*5 = 2 - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5BITS]; // 5-2 = 3 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5_BITS]; // 32-1*5 = 27 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5_BITS]; // 32-2*5 = 22 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5_BITS]; // 32-3*5 = 17 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5_BITS]; // 32-4*5 = 12 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5_BITS]; // 32-5*5 = 7 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5_BITS]; // 32-6*5 = 2 + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5_BITS]; // 5-2 = 3 buffer[context.pos++] = pad; break; default: @@ -616,14 +616,14 @@ public class Base32 extends BaseNCodec { } context.lbitWorkArea = (context.lbitWorkArea << 8) + b; // BITS_PER_BYTE if (0 == context.modulus) { // we have enough bytes to create our output - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5BITS]; - buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5_BITS]; + buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5_BITS]; context.currentLinePos += BYTES_PER_ENCODED_BLOCK; if (lineLength > 0 && lineLength <= context.currentLinePos) { System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java index 9780fc01..fe5066a4 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base64.java +++ b/src/main/java/org/apache/commons/codec/binary/Base64.java @@ -167,16 +167,16 @@ public class Base64 extends BaseNCodec { * Base64 uses 6-bit fields. */ /** Mask used to extract 6 bits, used when encoding */ - private static final int MASK_6BITS = 0x3f; + private static final int MASK_6_BITS = 0x3f; // The static final fields above are used for the original static byte[] methods on Base64. // The private member fields below are used with the new streaming approach, which requires // some state be preserved between calls of encode() and decode(). /** Mask used to extract 4 bits, used when decoding final trailing character. */ - private static final int MASK_4BITS = 0xf; + private static final int MASK_4_BITS = 0xf; /** Mask used to extract 2 bits, used when decoding final trailing character. */ - private static final int MASK_2BITS = 0x3; + private static final int MASK_2_BITS = 0x3; /** * Creates a new Builder. @@ -782,12 +782,12 @@ public class Base64 extends BaseNCodec { validateTrailingCharacter(); break; case 2 : // 12 bits = 8 + 4 - validateCharacter(MASK_4BITS, context); + validateCharacter(MASK_4_BITS, context); context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); break; case 3 : // 18 bits = 8 + 8 + 2 - validateCharacter(MASK_2BITS, context); + validateCharacter(MASK_2_BITS, context); context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits buffer[context.pos++] = (byte) (context.ibitWorkArea >> 8 & MASK_8BITS); buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); @@ -838,9 +838,9 @@ public class Base64 extends BaseNCodec { break; case 1 : // 8 bits = 6 + 2 // top 6 bits: - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 2 & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 2 & MASK_6_BITS]; // remaining 2: - buffer[context.pos++] = encodeTable[context.ibitWorkArea << 4 & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea << 4 & MASK_6_BITS]; // URL-SAFE skips the padding to further reduce size. if (encodeTable == STANDARD_ENCODE_TABLE) { buffer[context.pos++] = pad; @@ -849,9 +849,9 @@ public class Base64 extends BaseNCodec { break; case 2 : // 16 bits = 6 + 6 + 4 - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 10 & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 4 & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea << 2 & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 10 & MASK_6_BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 4 & MASK_6_BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea << 2 & MASK_6_BITS]; // URL-SAFE skips the padding to further reduce size. if (encodeTable == STANDARD_ENCODE_TABLE) { buffer[context.pos++] = pad; @@ -876,10 +876,10 @@ public class Base64 extends BaseNCodec { } context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 18 & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 12 & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 6 & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 18 & MASK_6_BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 12 & MASK_6_BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 6 & MASK_6_BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6_BITS]; context.currentLinePos += BYTES_PER_ENCODED_BLOCK; if (lineLength > 0 && lineLength <= context.currentLinePos) { System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);