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

commit d55b092d5f72aa9e039e122370332a16aa7f8f5f
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Apr 16 20:00:39 2024 -0400

    Internal refactoring
---
 .../org/apache/commons/codec/binary/Base16.java    | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 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 9d210dd7..65f75c42 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base16.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base16.java
@@ -133,17 +133,23 @@ public class Base16 extends BaseNCodec {
      * Constructs a Base16 codec used for decoding and encoding.
      *
      * @param lowerCase      if {@code true} then use a lower-case Base16 
alphabet.
+     * @param encodeTable    the encode table.
      * @param decodingPolicy Decoding policy.
      */
-    public Base16(final boolean lowerCase, final CodecPolicy decodingPolicy) {
+    private Base16(final boolean lowerCase, final byte[] encodeTable, final 
CodecPolicy decodingPolicy) {
         super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, 0, 0, 
PAD_DEFAULT, decodingPolicy);
-        if (lowerCase) {
-            this.encodeTable = LOWER_CASE_ENCODE_TABLE;
-            this.decodeTable = LOWER_CASE_DECODE_TABLE;
-        } else {
-            this.encodeTable = UPPER_CASE_ENCODE_TABLE;
-            this.decodeTable = UPPER_CASE_DECODE_TABLE;
-        }
+        this.encodeTable = encodeTable;
+        this.decodeTable = encodeTable == LOWER_CASE_ENCODE_TABLE ? 
LOWER_CASE_DECODE_TABLE : UPPER_CASE_DECODE_TABLE;
+    }
+
+    /**
+     * Constructs a Base16 codec used for decoding and encoding.
+     *
+     * @param lowerCase      if {@code true} then use a lower-case Base16 
alphabet.
+     * @param decodingPolicy Decoding policy.
+     */
+    public Base16(final boolean lowerCase, final CodecPolicy decodingPolicy) {
+        this(lowerCase, lowerCase ? LOWER_CASE_ENCODE_TABLE : 
UPPER_CASE_ENCODE_TABLE, decodingPolicy);
     }
 
     @Override

Reply via email to