Skip to content

Commit f83ca96

Browse files
committed
Deprecate Base32 constructors in favor of the builder added in version
1.17.0
1 parent 05f0bfc commit f83ca96

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ 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>
4849
<!-- ADD -->
4950
<action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
5051
<!-- UPDATE -->

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

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939
* This class is thread-safe.
4040
* </p>
4141
* <p>
42-
* You can configure instances with the {@link Builder}.
42+
* To configure a new instance, use a {@link Builder}. For example:
4343
* </p>
4444
* <pre>
4545
* Base32 base32 = Base32.builder()
4646
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient
47-
* .setEncodeTable(customEncodeTable)
4847
* .setLineLength(0) // default is none
4948
* .setLineSeparator('\r', '\n') // default is CR LF
50-
* .setPadding('=') // default is =
49+
* .setPadding('=') // default is '='
50+
* .setEncodeTable(customEncodeTable) // default is RFC 4648 Section 6, Table 3: The Base 32 Alphabet
5151
* .get()
5252
* </pre>
5353
*
@@ -61,6 +61,20 @@ public class Base32 extends BaseNCodec {
6161
/**
6262
* Builds {@link Base32} instances.
6363
*
64+
* <p>
65+
* To configure a new instance, use a {@link Builder}. For example:
66+
* </p>
67+
*
68+
* <pre>
69+
* Base32 base32 = Base32.builder()
70+
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient
71+
* .setLineLength(0) // default is none
72+
* .setLineSeparator('\r', '\n') // default is CR LF
73+
* .setPadding('=') // default is '='
74+
* .setEncodeTable(customEncodeTable) // default is RFC 4648 Section 6, Table 3: The Base 32 Alphabet
75+
* .get()
76+
* </pre>
77+
*
6478
* @since 1.17.0
6579
*/
6680
public static class Builder extends AbstractBuilder<Base32, Builder> {
@@ -212,6 +226,20 @@ public Builder setHexEncodeTable(final boolean useHex) {
212226
/**
213227
* Creates a new Builder.
214228
*
229+
* <p>
230+
* To configure a new instance, use a {@link Builder}. For example:
231+
* </p>
232+
*
233+
* <pre>
234+
* Base32 base32 = Base32.builder()
235+
* .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient
236+
* .setLineLength(0) // default is none
237+
* .setLineSeparator('\r', '\n') // default is CR LF
238+
* .setPadding('=') // default is '='
239+
* .setEncodeTable(customEncodeTable) // default is RFC 4648 Section 6, Table 3: The Base 32 Alphabet
240+
* .get()
241+
* </pre>
242+
*
215243
* @return a new Builder.
216244
* @since 1.17.0
217245
*/
@@ -283,7 +311,9 @@ public Base32() {
283311
* <li>If false, then use <a href="https://datatracker.ietf.org/doc/html/rfc4648#section-6">RFC 4648 Section 6, Table 3: The Base 32
284312
* Alphabet</a></li>
285313
* </ul>
314+
* @deprecated Use {@link #builder()} and {@link Builder}.
286315
*/
316+
@Deprecated
287317
public Base32(final boolean useHex) {
288318
this(0, null, useHex, PAD_DEFAULT);
289319
}
@@ -302,7 +332,9 @@ public Base32(final boolean useHex) {
302332
* Alphabet</a></li>
303333
* </ul>
304334
* @param padding byte used as padding byte.
335+
* @deprecated Use {@link #builder()} and {@link Builder}.
305336
*/
337+
@Deprecated
306338
public Base32(final boolean useHex, final byte padding) {
307339
this(0, null, useHex, padding);
308340
}
@@ -314,7 +346,9 @@ public Base32(final boolean useHex, final byte padding) {
314346
* </p>
315347
*
316348
* @param pad byte used as padding byte.
349+
* @deprecated Use {@link #builder()} and {@link Builder}.
317350
*/
351+
@Deprecated
318352
public Base32(final byte pad) {
319353
this(false, pad);
320354
}
@@ -327,7 +361,9 @@ public Base32(final byte pad) {
327361
*
328362
* @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength &lt;= 0, then
329363
* the output will not be divided into lines (chunks). Ignored when decoding.
364+
* @deprecated Use {@link #builder()} and {@link Builder}.
330365
*/
366+
@Deprecated
331367
public Base32(final int lineLength) {
332368
this(lineLength, CHUNK_SEPARATOR);
333369
}
@@ -345,7 +381,9 @@ public Base32(final int lineLength) {
345381
* then the output will not be divided into lines (chunks). Ignored when decoding.
346382
* @param lineSeparator Each line of encoded data will end with this sequence of bytes.
347383
* @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters.
384+
* @deprecated Use {@link #builder()} and {@link Builder}.
348385
*/
386+
@Deprecated
349387
public Base32(final int lineLength, final byte[] lineSeparator) {
350388
this(lineLength, lineSeparator, false, PAD_DEFAULT);
351389
}
@@ -370,7 +408,9 @@ public Base32(final int lineLength, final byte[] lineSeparator) {
370408
* Alphabet</a></li>
371409
* </ul>
372410
* @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null.
411+
* @deprecated Use {@link #builder()} and {@link Builder}.
373412
*/
413+
@Deprecated
374414
public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex) {
375415
this(lineLength, lineSeparator, useHex, PAD_DEFAULT);
376416
}
@@ -396,7 +436,9 @@ public Base32(final int lineLength, final byte[] lineSeparator, final boolean us
396436
* </ul>
397437
* @param padding padding byte.
398438
* @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null.
439+
* @deprecated Use {@link #builder()} and {@link Builder}.
399440
*/
441+
@Deprecated
400442
public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex, final byte padding) {
401443
this(lineLength, lineSeparator, useHex, padding, DECODING_POLICY_DEFAULT);
402444
}
@@ -424,7 +466,9 @@ public Base32(final int lineLength, final byte[] lineSeparator, final boolean us
424466
* @param decodingPolicy The decoding policy.
425467
* @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null.
426468
* @since 1.15
469+
* @deprecated Use {@link #builder()} and {@link Builder}.
427470
*/
471+
@Deprecated
428472
public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex, final byte padding, final CodecPolicy decodingPolicy) {
429473
this(lineLength, lineSeparator, encodeTable(useHex), padding, decodingPolicy);
430474
}

0 commit comments

Comments
 (0)