You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/04/17 00:00:46 UTC
(commons-codec) 01/03: Pull-up common Builder attribute to BaseNCodec
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 4791d3b33f7513b11bc025e594aa747a258d3e70
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Apr 16 19:42:03 2024 -0400
Pull-up common Builder attribute to BaseNCodec
---
.../java/org/apache/commons/codec/binary/Base32.java | 16 +---------------
.../org/apache/commons/codec/binary/BaseNCodec.java | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 16 deletions(-)
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 8b54b8b7..61ca1140 100644
--- a/src/main/java/org/apache/commons/codec/binary/Base32.java
+++ b/src/main/java/org/apache/commons/codec/binary/Base32.java
@@ -49,9 +49,6 @@ public class Base32 extends BaseNCodec {
*/
public static class Builder extends AbstractBuilder<Base32, Builder> {
- /** Padding byte. */
- private byte padding = PAD_DEFAULT;
-
/**
* Constructs a new instance.
*/
@@ -61,18 +58,7 @@ public class Base32 extends BaseNCodec {
@Override
public Base32 get() {
- return new Base32(getLineLength(), getLineSeparator(), getEncodeTable(), padding, getDecodingPolicy());
- }
-
- /**
- * Sets the padding byte.
- *
- * @param padding the padding byte.
- * @return this.
- */
- public Builder setPadding(final byte padding) {
- this.padding = padding;
- return this;
+ return new Base32(getLineLength(), getLineSeparator(), getEncodeTable(), getPadding(), getDecodingPolicy());
}
}
diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index 9c377641..df68641a 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -66,7 +66,8 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
private byte[] lineSeparator = CHUNK_SEPARATOR;
private final byte[] defaultEncodeTable;
private byte[] encodeTable;
-
+ /** Padding byte. */
+ private byte padding = PAD_DEFAULT;
AbstractBuilder(final byte[] defaultEncodeTable) {
this.defaultEncodeTable = defaultEncodeTable;
@@ -94,6 +95,10 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
return lineSeparator;
}
+ byte getPadding() {
+ return padding;
+ }
+
/**
* Sets the decoding policy.
*
@@ -138,6 +143,17 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
return asThis();
}
+ /**
+ * Sets the padding byte.
+ *
+ * @param padding the padding byte.
+ * @return this.
+ */
+ public B setPadding(final byte padding) {
+ this.padding = padding;
+ return asThis();
+ }
+
}
/**