Skip to content

Commit 729bdc8

Browse files
committed
Rename private constants
1 parent a7d39e3 commit 729bdc8

File tree

3 files changed

+52
-52
lines changed

3 files changed

+52
-52
lines changed

src/main/java/org/apache/commons/codec/binary/Base16.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class Base16 extends BaseNCodec {
9292
private static final byte[] LOWER_CASE_ENCODE_TABLE = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
9393

9494
/** Mask used to extract 4 bits, used when decoding character. */
95-
private static final int MASK_4BITS = 0x0f;
95+
private static final int MASK_4_BITS = 0x0f;
9696

9797
/**
9898
* Decode table to use.
@@ -215,8 +215,8 @@ void encode(final byte[] data, final int offset, final int length, final Context
215215
final int end = offset + length;
216216
for (int i = offset; i < end; i++) {
217217
final int value = data[i];
218-
final int high = value >> BITS_PER_ENCODED_BYTE & MASK_4BITS;
219-
final int low = value & MASK_4BITS;
218+
final int high = value >> BITS_PER_ENCODED_BYTE & MASK_4_BITS;
219+
final int low = value & MASK_4_BITS;
220220
buffer[context.pos++] = encodeTable[high];
221221
buffer[context.pos++] = encodeTable[low];
222222
}

src/main/java/org/apache/commons/codec/binary/Base32.java

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,19 @@ public Builder setHexEncodeTable(final boolean useHex) {
175175
// @formatter:on
176176

177177
/** Mask used to extract 5 bits, used when encoding Base32 bytes */
178-
private static final int MASK_5BITS = 0x1f;
178+
private static final int MASK_5_BITS = 0x1f;
179179

180180
/** Mask used to extract 4 bits, used when decoding final trailing character. */
181-
private static final long MASK_4BITS = 0x0fL;
181+
private static final long MASK_4_BITS = 0x0fL;
182182

183183
/** Mask used to extract 3 bits, used when decoding final trailing character. */
184-
private static final long MASK_3BITS = 0x07L;
184+
private static final long MASK_3_BITS = 0x07L;
185185

186186
/** Mask used to extract 2 bits, used when decoding final trailing character. */
187-
private static final long MASK_2BITS = 0x03L;
187+
private static final long MASK_2_BITS = 0x03L;
188188

189189
/** Mask used to extract 1 bits, used when decoding final trailing character. */
190-
private static final long MASK_1BITS = 0x01L;
190+
private static final long MASK_1_BITS = 0x01L;
191191

192192
// The static final fields above are used for the original static byte[] methods on Base32.
193193
// The private member fields below are used with the new streaming approach, which requires
@@ -484,7 +484,7 @@ void decode(final byte[] input, int inPos, final int inAvail, final Context cont
484484
validateTrailingCharacters();
485485
// falls-through
486486
case 2: // 10 bits, drop 2 and output one byte
487-
validateCharacter(MASK_2BITS, context);
487+
validateCharacter(MASK_2_BITS, context);
488488
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 2 & MASK_8BITS);
489489
break;
490490
case 3: // 15 bits, drop 7 and output 1 byte, or raise an exception
@@ -493,13 +493,13 @@ void decode(final byte[] input, int inPos, final int inAvail, final Context cont
493493
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 7 & MASK_8BITS);
494494
break;
495495
case 4: // 20 bits = 2*8 + 4
496-
validateCharacter(MASK_4BITS, context);
496+
validateCharacter(MASK_4_BITS, context);
497497
context.lbitWorkArea = context.lbitWorkArea >> 4; // drop 4 bits
498498
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);
499499
buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);
500500
break;
501501
case 5: // 25 bits = 3*8 + 1
502-
validateCharacter(MASK_1BITS, context);
502+
validateCharacter(MASK_1_BITS, context);
503503
context.lbitWorkArea = context.lbitWorkArea >> 1;
504504
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);
505505
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);
@@ -514,7 +514,7 @@ void decode(final byte[] input, int inPos, final int inAvail, final Context cont
514514
buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);
515515
break;
516516
case 7: // 35 bits = 4*8 +3
517-
validateCharacter(MASK_3BITS, context);
517+
validateCharacter(MASK_3_BITS, context);
518518
context.lbitWorkArea = context.lbitWorkArea >> 3;
519519
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS);
520520
buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);
@@ -558,8 +558,8 @@ void encode(final byte[] input, int inPos, final int inAvail, final Context cont
558558
case 0:
559559
break;
560560
case 1: // Only 1 octet; take top 5 bits then remainder
561-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5BITS]; // 8-1*5 = 3
562-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5BITS]; // 5-3=2
561+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5_BITS]; // 8-1*5 = 3
562+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5_BITS]; // 5-3=2
563563
buffer[context.pos++] = pad;
564564
buffer[context.pos++] = pad;
565565
buffer[context.pos++] = pad;
@@ -568,33 +568,33 @@ void encode(final byte[] input, int inPos, final int inAvail, final Context cont
568568
buffer[context.pos++] = pad;
569569
break;
570570
case 2: // 2 octets = 16 bits to use
571-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5BITS]; // 16-1*5 = 11
572-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5BITS]; // 16-2*5 = 6
573-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5BITS]; // 16-3*5 = 1
574-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5BITS]; // 5-1 = 4
571+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5_BITS]; // 16-1*5 = 11
572+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5_BITS]; // 16-2*5 = 6
573+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5_BITS]; // 16-3*5 = 1
574+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5_BITS]; // 5-1 = 4
575575
buffer[context.pos++] = pad;
576576
buffer[context.pos++] = pad;
577577
buffer[context.pos++] = pad;
578578
buffer[context.pos++] = pad;
579579
break;
580580
case 3: // 3 octets = 24 bits to use
581-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5BITS]; // 24-1*5 = 19
582-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5BITS]; // 24-2*5 = 14
583-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5BITS]; // 24-3*5 = 9
584-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5BITS]; // 24-4*5 = 4
585-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5BITS]; // 5-4 = 1
581+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5_BITS]; // 24-1*5 = 19
582+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5_BITS]; // 24-2*5 = 14
583+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5_BITS]; // 24-3*5 = 9
584+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5_BITS]; // 24-4*5 = 4
585+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5_BITS]; // 5-4 = 1
586586
buffer[context.pos++] = pad;
587587
buffer[context.pos++] = pad;
588588
buffer[context.pos++] = pad;
589589
break;
590590
case 4: // 4 octets = 32 bits to use
591-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5BITS]; // 32-1*5 = 27
592-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5BITS]; // 32-2*5 = 22
593-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5BITS]; // 32-3*5 = 17
594-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5BITS]; // 32-4*5 = 12
595-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5BITS]; // 32-5*5 = 7
596-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5BITS]; // 32-6*5 = 2
597-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5BITS]; // 5-2 = 3
591+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5_BITS]; // 32-1*5 = 27
592+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5_BITS]; // 32-2*5 = 22
593+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5_BITS]; // 32-3*5 = 17
594+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5_BITS]; // 32-4*5 = 12
595+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5_BITS]; // 32-5*5 = 7
596+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5_BITS]; // 32-6*5 = 2
597+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5_BITS]; // 5-2 = 3
598598
buffer[context.pos++] = pad;
599599
break;
600600
default:
@@ -616,14 +616,14 @@ void encode(final byte[] input, int inPos, final int inAvail, final Context cont
616616
}
617617
context.lbitWorkArea = (context.lbitWorkArea << 8) + b; // BITS_PER_BYTE
618618
if (0 == context.modulus) { // we have enough bytes to create our output
619-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5BITS];
620-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5BITS];
621-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5BITS];
622-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5BITS];
623-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5BITS];
624-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5BITS];
625-
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5BITS];
626-
buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5BITS];
619+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5_BITS];
620+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5_BITS];
621+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5_BITS];
622+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5_BITS];
623+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5_BITS];
624+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5_BITS];
625+
buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5_BITS];
626+
buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5_BITS];
627627
context.currentLinePos += BYTES_PER_ENCODED_BLOCK;
628628
if (lineLength > 0 && lineLength <= context.currentLinePos) {
629629
System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);

src/main/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ public Builder setUrlSafe(final boolean urlSafe) {
167167
* Base64 uses 6-bit fields.
168168
*/
169169
/** Mask used to extract 6 bits, used when encoding */
170-
private static final int MASK_6BITS = 0x3f;
170+
private static final int MASK_6_BITS = 0x3f;
171171

172172
// The static final fields above are used for the original static byte[] methods on Base64.
173173
// The private member fields below are used with the new streaming approach, which requires
174174
// some state be preserved between calls of encode() and decode().
175175

176176
/** Mask used to extract 4 bits, used when decoding final trailing character. */
177-
private static final int MASK_4BITS = 0xf;
177+
private static final int MASK_4_BITS = 0xf;
178178
/** Mask used to extract 2 bits, used when decoding final trailing character. */
179-
private static final int MASK_2BITS = 0x3;
179+
private static final int MASK_2_BITS = 0x3;
180180

181181
/**
182182
* Creates a new Builder.
@@ -782,12 +782,12 @@ void decode(final byte[] input, int inPos, final int inAvail, final Context cont
782782
validateTrailingCharacter();
783783
break;
784784
case 2 : // 12 bits = 8 + 4
785-
validateCharacter(MASK_4BITS, context);
785+
validateCharacter(MASK_4_BITS, context);
786786
context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits
787787
buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
788788
break;
789789
case 3 : // 18 bits = 8 + 8 + 2
790-
validateCharacter(MASK_2BITS, context);
790+
validateCharacter(MASK_2_BITS, context);
791791
context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits
792792
buffer[context.pos++] = (byte) (context.ibitWorkArea >> 8 & MASK_8BITS);
793793
buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS);
@@ -838,9 +838,9 @@ void encode(final byte[] in, int inPos, final int inAvail, final Context context
838838
break;
839839
case 1 : // 8 bits = 6 + 2
840840
// top 6 bits:
841-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 2 & MASK_6BITS];
841+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 2 & MASK_6_BITS];
842842
// remaining 2:
843-
buffer[context.pos++] = encodeTable[context.ibitWorkArea << 4 & MASK_6BITS];
843+
buffer[context.pos++] = encodeTable[context.ibitWorkArea << 4 & MASK_6_BITS];
844844
// URL-SAFE skips the padding to further reduce size.
845845
if (encodeTable == STANDARD_ENCODE_TABLE) {
846846
buffer[context.pos++] = pad;
@@ -849,9 +849,9 @@ void encode(final byte[] in, int inPos, final int inAvail, final Context context
849849
break;
850850

851851
case 2 : // 16 bits = 6 + 6 + 4
852-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 10 & MASK_6BITS];
853-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 4 & MASK_6BITS];
854-
buffer[context.pos++] = encodeTable[context.ibitWorkArea << 2 & MASK_6BITS];
852+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 10 & MASK_6_BITS];
853+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 4 & MASK_6_BITS];
854+
buffer[context.pos++] = encodeTable[context.ibitWorkArea << 2 & MASK_6_BITS];
855855
// URL-SAFE skips the padding to further reduce size.
856856
if (encodeTable == STANDARD_ENCODE_TABLE) {
857857
buffer[context.pos++] = pad;
@@ -876,10 +876,10 @@ void encode(final byte[] in, int inPos, final int inAvail, final Context context
876876
}
877877
context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE
878878
if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract
879-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 18 & MASK_6BITS];
880-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 12 & MASK_6BITS];
881-
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 6 & MASK_6BITS];
882-
buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS];
879+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 18 & MASK_6_BITS];
880+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 12 & MASK_6_BITS];
881+
buffer[context.pos++] = encodeTable[context.ibitWorkArea >> 6 & MASK_6_BITS];
882+
buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6_BITS];
883883
context.currentLinePos += BYTES_PER_ENCODED_BLOCK;
884884
if (lineLength > 0 && lineLength <= context.currentLinePos) {
885885
System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);

0 commit comments

Comments
 (0)