Skip to content

Commit 4488b9d

Browse files
committed
Deprecate all but one Base64 constructor in favor of the builder added
in version 1.17.0
1 parent f83ca96 commit 4488b9d

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

src/changes/changes.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ The <action> type attribute can be add,update,fix,remove.
4545
<body>
4646
<release version="1.20.0" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required.">
4747
<!-- FIX -->
48-
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate Base32 constructors in favor of the builder added in version 1.17.0.</action>
48+
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate all but one Base32 constructor in favor of the builder added in version 1.17.0.</action>
49+
<action type="update" dev="ggregory" due-to="Gary Gregory">Deprecate all but one Base64 constructor in favor of the builder added in version 1.17.0.</action>
4950
<!-- ADD -->
5051
<action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
5152
<!-- UPDATE -->

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public Builder setHexEncodeTable(final boolean useHex) {
172172
/**
173173
* This array is a lookup table that translates Unicode characters drawn from the "Base32 Hex Alphabet" (as specified in Table 4 of RFC 4648) into their
174174
* 5-bit positive integer equivalents. Characters that are not in the Base32 Hex alphabet but fall within the bounds of the array are translated to -1.
175-
*
176175
*/
177176
// @formatter:off
178177
private static final byte[] HEX_DECODE_TABLE = {

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
* This class is thread-safe.
5252
* </p>
5353
* <p>
54-
* You can configure instances with the {@link Builder}.
54+
* To configure a new instance, use a {@link Builder}. For example:
5555
* </p>
5656
* <pre>
5757
* Base64 base64 = Base64.builder()
5858
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient, null resets to default
5959
* .setEncodeTable(customEncodeTable) // default is built in, null resets to default
6060
* .setLineLength(0) // default is none
6161
* .setLineSeparator('\r', '\n') // default is CR LF, null resets to default
62-
* .setPadding('=') // default is =
62+
* .setPadding('=') // default is '='
6363
* .setUrlSafe(false) // default is false
6464
* .get()
6565
* </pre>
@@ -74,6 +74,21 @@ public class Base64 extends BaseNCodec {
7474
/**
7575
* Builds {@link Base64} instances.
7676
*
77+
* <p>
78+
* To configure a new instance, use a {@link Builder}. For example:
79+
* </p>
80+
*
81+
* <pre>
82+
* Base64 base64 = Base64.builder()
83+
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient, null resets to default
84+
* .setEncodeTable(customEncodeTable) // default is built in, null resets to default
85+
* .setLineLength(0) // default is none
86+
* .setLineSeparator('\r', '\n') // default is CR LF, null resets to default
87+
* .setPadding('=') // default is '='
88+
* .setUrlSafe(false) // default is false
89+
* .get()
90+
* </pre>
91+
*
7792
* @since 1.17.0
7893
*/
7994
public static class Builder extends AbstractBuilder<Base64, Builder> {
@@ -183,6 +198,21 @@ public Builder setUrlSafe(final boolean urlSafe) {
183198
/**
184199
* Creates a new Builder.
185200
*
201+
* <p>
202+
* To configure a new instance, use a {@link Builder}. For example:
203+
* </p>
204+
*
205+
* <pre>
206+
* Base64 base64 = Base64.builder()
207+
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient, null resets to default
208+
* .setEncodeTable(customEncodeTable) // default is built in, null resets to default
209+
* .setLineLength(0) // default is none
210+
* .setLineSeparator('\r', '\n') // default is CR LF, null resets to default
211+
* .setPadding('=') // default is '='
212+
* .setUrlSafe(false) // default is false
213+
* .get()
214+
* </pre>
215+
*
186216
* @return a new Builder.
187217
* @since 1.17.0
188218
*/
@@ -525,7 +555,9 @@ public Base64() {
525555
* if {@code true}, URL-safe encoding is used. In most cases this should be set to
526556
* {@code false}.
527557
* @since 1.4
558+
* @deprecated Use {@link #builder()} and {@link Builder}.
528559
*/
560+
@Deprecated
529561
public Base64(final boolean urlSafe) {
530562
this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe);
531563
}
@@ -548,7 +580,9 @@ public Base64(final boolean urlSafe) {
548580
* 4). If lineLength &lt;= 0, then the output will not be divided into lines (chunks). Ignored when
549581
* decoding.
550582
* @since 1.4
583+
* @deprecated Use {@link #builder()} and {@link Builder}.
551584
*/
585+
@Deprecated
552586
public Base64(final int lineLength) {
553587
this(lineLength, CHUNK_SEPARATOR);
554588
}
@@ -575,7 +609,9 @@ public Base64(final int lineLength) {
575609
* @throws IllegalArgumentException
576610
* Thrown when the provided lineSeparator included some base64 characters.
577611
* @since 1.4
612+
* @deprecated Use {@link #builder()} and {@link Builder}.
578613
*/
614+
@Deprecated
579615
public Base64(final int lineLength, final byte[] lineSeparator) {
580616
this(lineLength, lineSeparator, false);
581617
}
@@ -606,7 +642,9 @@ public Base64(final int lineLength, final byte[] lineSeparator) {
606642
* @throws IllegalArgumentException
607643
* Thrown when the {@code lineSeparator} contains Base64 characters.
608644
* @since 1.4
645+
* @deprecated Use {@link #builder()} and {@link Builder}.
609646
*/
647+
@Deprecated
610648
public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) {
611649
this(lineLength, lineSeparator, PAD_DEFAULT, toUrlSafeEncodeTable(urlSafe), DECODING_POLICY_DEFAULT);
612650
}
@@ -638,7 +676,9 @@ public Base64(final int lineLength, final byte[] lineSeparator, final boolean ur
638676
* @throws IllegalArgumentException
639677
* Thrown when the {@code lineSeparator} contains Base64 characters.
640678
* @since 1.15
679+
* @deprecated Use {@link #builder()} and {@link Builder}.
641680
*/
681+
@Deprecated
642682
public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe, final CodecPolicy decodingPolicy) {
643683
this(lineLength, lineSeparator, PAD_DEFAULT, toUrlSafeEncodeTable(urlSafe), decodingPolicy);
644684
}

0 commit comments

Comments
 (0)