Skip to content

Commit 42de020

Browse files
committed
Internal refactoring
Deprecate some old constructors
1 parent c5f66c9 commit 42de020

File tree

4 files changed

+128
-210
lines changed

4 files changed

+128
-210
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.commons.codec.binary;
1919

2020
import java.util.Arrays;
21-
import java.util.Objects;
2221

2322
import org.apache.commons.codec.CodecPolicy;
2423

@@ -157,11 +156,6 @@ public static Builder builder() {
157156
*/
158157
private final byte[] decodeTable;
159158

160-
/**
161-
* Encode table to use.
162-
*/
163-
private final byte[] encodeTable;
164-
165159
/**
166160
* Constructs a Base16 codec used for decoding and encoding.
167161
*/
@@ -194,7 +188,6 @@ public Base16(final boolean lowerCase, final CodecPolicy decodingPolicy) {
194188

195189
private Base16(final Builder builder) {
196190
super(builder);
197-
this.encodeTable = Objects.requireNonNull(builder.getEncodeTable(), "encodeTable");
198191
this.decodeTable = Arrays.equals(encodeTable, LOWER_CASE_ENCODE_TABLE) ? LOWER_CASE_DECODE_TABLE : UPPER_CASE_DECODE_TABLE;
199192
}
200193

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ private static byte[] encodeTable(final boolean useHex) {
280280
*/
281281
private final int encodeSize;
282282

283-
/**
284-
* Encode table to use.
285-
*/
286-
private final byte[] encodeTable;
287-
288283
/**
289284
* Line separator for encoding. Not used when decoding. Only used if lineLength > 0.
290285
*/
@@ -344,7 +339,6 @@ public Base32(final boolean useHex, final byte padding) {
344339
private Base32(final Builder builder) {
345340
super(builder);
346341
Objects.requireNonNull(builder.getEncodeTable(), "encodeTable");
347-
this.encodeTable = builder.getEncodeTable();
348342
this.decodeTable = Arrays.equals(builder.getEncodeTable(), HEX_ENCODE_TABLE) ? HEX_DECODE_TABLE : DECODE_TABLE;
349343
if (builder.getLineLength() > 0) {
350344
final byte[] lineSeparator = builder.getLineSeparator();

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,6 @@ static byte[] toUrlSafeEncodeTable(final boolean urlSafe) {
505505
return urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE;
506506
}
507507

508-
/**
509-
* Encode table to use: either STANDARD or URL_SAFE or custom.
510-
* Note: the DECODE_TABLE above remains static because it is able
511-
* to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch
512-
* between the two modes.
513-
*/
514-
private final byte[] encodeTable;
515-
516508
/**
517509
* Decode table to use.
518510
*/
@@ -698,7 +690,6 @@ private Base64(final Builder builder) {
698690
}
699691
this.isStandardEncodeTable = Arrays.equals(builder.getEncodeTable(), STANDARD_ENCODE_TABLE);
700692
this.isUrlSafe = Arrays.equals(builder.getEncodeTable(), URL_SAFE_ENCODE_TABLE);
701-
this.encodeTable = builder.getEncodeTable();
702693
this.decodeTable = this.isStandardEncodeTable || this.isUrlSafe ? DECODE_TABLE : calculateDecodeTable(this.encodeTable);
703694
// TODO could be simplified if there is no requirement to reject invalid line sep when length <=0
704695
// @see test case Base64Test.testConstructors()

0 commit comments

Comments
 (0)