@@ -113,12 +113,14 @@ public Base64 get() {
113113 public Builder setEncodeTable (final byte ... encodeTable ) {
114114 final boolean isStandardEncodeTable = Arrays .equals (encodeTable , STANDARD_ENCODE_TABLE );
115115 final boolean isUrlSafe = Arrays .equals (encodeTable , URL_SAFE_ENCODE_TABLE );
116- super . setDecodeTableRaw (isStandardEncodeTable || isUrlSafe ? DECODE_TABLE : calculateDecodeTable (encodeTable ));
116+ setDecodeTableRaw (isStandardEncodeTable || isUrlSafe ? DECODE_TABLE : calculateDecodeTable (encodeTable ));
117117 return super .setEncodeTable (encodeTable );
118118 }
119119
120120 /**
121121 * Sets the URL-safe encoding policy.
122+ * This method does not modify behavior on decoding operations. For configuration of the decoding behavior,
123+ * please use {@link #setDecodeTableFormat} method.
122124 *
123125 * @param urlSafe URL-safe encoding policy, null resets to the default.
124126 * @return {@code this} instance.
@@ -130,33 +132,38 @@ public Builder setUrlSafe(final boolean urlSafe) {
130132 /**
131133 * Sets the format of the decoding table.
132134 * This method allows to explicitly state whether a "standard" or "URL Safe" Base64 decoding is expected.
135+ * This method does not modify behavior on encoding operations. For configuration of the encoding behavior,
136+ * please use {@link #setUrlSafe} method.
133137 * <p>
134- * Note: By default, the implementation uses the MIXED approach, allowing a seamless handling of
135- * both URL_SAFE and STANDARD base64.
138+ * Note: By default, the implementation uses the {@link DecodeTableFormat# MIXED} approach, allowing a
139+ * seamless handling of both {@link DecodeTableFormat# URL_SAFE} and {@link DecodeTableFormat# STANDARD} base64.
136140 * </p>
137141 *
138142 * @param format table format to be used on Base64 decoding.
143+ * Use {@link DecodeTableFormat#MIXED} or null to reset to the default behavior.
139144 * @return {@code this} instance.
140145 */
141146 public Builder setDecodeTableFormat (final DecodeTableFormat format ) {
147+ if (format == null ) {
148+ return setDecodeTableRaw (DECODE_TABLE );
149+ }
142150 switch (format ) {
143151 case STANDARD :
144- return super . setDecodeTableRaw (STANDARD_DECODE_TABLE );
152+ return setDecodeTableRaw (STANDARD_DECODE_TABLE );
145153 case URL_SAFE :
146- return super . setDecodeTableRaw (URL_SAFE_DECODE_TABLE );
154+ return setDecodeTableRaw (URL_SAFE_DECODE_TABLE );
147155 case MIXED :
148156 default :
149- return super . setDecodeTableRaw (DECODE_TABLE );
157+ return setDecodeTableRaw (DECODE_TABLE );
150158 }
151159 }
152160
153161 }
154162
155163 /**
156- * Defines the Base64 table format to be used on decoding
157- * <p>
158- * Note: By default, the MIXED approach is used, allowing a seamless handling of both URL_SAFE and STANDARD base64.
159- * </p>
164+ * Defines the Base64 table format to be used on decoding.
165+ * By default, the method uses {@link DecodeTableFormat#MIXED} approach, allowing a seamless handling of
166+ * both {@link DecodeTableFormat#URL_SAFE} and {@link DecodeTableFormat#STANDARD} base64 options.
160167 */
161168 public enum DecodeTableFormat {
162169
@@ -173,9 +180,7 @@ public enum DecodeTableFormat {
173180 /**
174181 * Represents a joint approach, allowing a seamless decoding of both character sets,
175182 * corresponding to either Table 1 of RFC 2045 or Table 2 of RFC 4648.
176- * <p>
177- * Note: This decoding table is used by default.
178- * </p>
183+ * This decoding table is used by default.
179184 */
180185 MIXED
181186
@@ -233,7 +238,7 @@ public enum DecodeTableFormat {
233238 * </p>
234239 */
235240 private static final byte [] DECODE_TABLE = {
236- // 0 1 2 3 4 5 6 7 8 9 A B C D E F
241+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F
237242 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , // 00-0f
238243 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , // 10-1f
239244 -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 62 , -1 , 62 , -1 , 63 , // 20-2f + - /
@@ -248,10 +253,8 @@ public enum DecodeTableFormat {
248253 * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified
249254 * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64
250255 * alphabet but fall within the bounds of the array are translated to -1.
251- * <p>
252- * Note: This decoding table handles only the "standard" base64 characters, such as '+' and '/'.
256+ * This decoding table handles only the "standard" base64 characters, such as '+' and '/'.
253257 * The "url-safe" characters such as '-' and '_' are not supported by the table.
254- * </p>
255258 */
256259 private static final byte [] STANDARD_DECODE_TABLE = {
257260 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
@@ -270,10 +273,8 @@ public enum DecodeTableFormat {
270273 * (as specified in Table 2 of RFC 4648) into their 6-bit positive integer equivalents.
271274 * Characters that are not in the Base64 URL Safe alphabet but fall within the bounds of the array
272275 * are translated to -1.
273- * <p>
274- * Note: This decoding table handles only the "URL Safe" base64 characters, such as '-' and '_'.
276+ * This decoding table handles only the "URL Safe" base64 characters, such as '-' and '_'.
275277 * The "standard" characters such as '+' and '/' are not supported by the table.
276- * </p>
277278 */
278279 private static final byte [] URL_SAFE_DECODE_TABLE = {
279280 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
@@ -347,15 +348,13 @@ private static byte[] calculateDecodeTable(final byte[] encodeTable) {
347348 * <p>
348349 * <strong>Note:</strong> this method seamlessly handles data encoded in URL-safe or normal mode.
349350 * For enforcing verification against strict standard Base64 or Base64 URL Safe tables,
350- * please use {@code #decodeBase64Standard} or {@code decodeBase64Url} methods respectively.
351- * </p>
352- * <p>
353- * <strong>Note 2:</strong> this method skips any unknown or not supported bytes.
351+ * please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively.
352+ * This method skips any unknown or not supported bytes.
354353 * </p>
355354 *
356355 * @param base64Data
357356 * Byte array containing Base64 data
358- * @return Array containing decoded data.
357+ * @return New array containing decoded data.
359358 */
360359 public static byte [] decodeBase64 (final byte [] base64Data ) {
361360 return new Base64 ().decode (base64Data );
@@ -366,15 +365,13 @@ public static byte[] decodeBase64(final byte[] base64Data) {
366365 * <p>
367366 * <strong>Note:</strong> this method seamlessly handles data encoded in URL-safe or normal mode.
368367 * For enforcing verification against strict standard Base64 or Base64 URL Safe tables,
369- * please use {@code #decodeBase64Standard} or {@code decodeBase64Url} methods respectively.
370- * </p>
371- * <p>
372- * <strong>Note 2:</strong> this method skips any unknown or not supported characters.
368+ * please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively.
369+ * This method skips any unknown or not supported bytes.
373370 * </p>
374371 *
375372 * @param base64String
376373 * String containing Base64 data
377- * @return Array containing decoded data.
374+ * @return New array containing decoded data.
378375 * @since 1.4
379376 */
380377 public static byte [] decodeBase64 (final String base64String ) {
@@ -385,14 +382,12 @@ public static byte[] decodeBase64(final String base64String) {
385382 * Decodes standard Base64 data into octets.
386383 * <p>
387384 * Note: implementation of this method is aligned with the Table 1 of RFC 2045.
388- * </p>
389- * <p>
390- * Note 2 this method skips any unknown or not supported bytes.
385+ * This method skips any unknown or not supported bytes.
391386 * </p>
392387 *
393388 * @param base64Data
394389 * Byte array containing Base64 data
395- * @return Array containing decoded data.
390+ * @return New array containing decoded data.
396391 * @since 1.21
397392 */
398393 public static byte [] decodeBase64Standard (final byte [] base64Data ) {
@@ -403,14 +398,12 @@ public static byte[] decodeBase64Standard(final byte[] base64Data) {
403398 * Decodes a standard Base64 String into octets.
404399 * <p>
405400 * Note: implementation of this method is aligned with the Table 1 of RFC 2045.
406- * </p>
407- * <p>
408- * Note 2: this method skips any unknown or not supported characters.
401+ * This method skips any unknown or not supported characters.
409402 * </p>
410403 *
411404 * @param base64String
412405 * String containing Base64 data
413- * @return Array containing decoded data.
406+ * @return New array containing decoded data.
414407 * @since 1.21
415408 */
416409 public static byte [] decodeBase64Standard (final String base64String ) {
@@ -421,14 +414,12 @@ public static byte[] decodeBase64Standard(final String base64String) {
421414 * Decodes URL Safe Base64 data into octets.
422415 * <p>
423416 * Note: implementation of this method is aligned with the Table 2 of RFC 4648.
424- * </p>
425- * <p>
426- * Note 2 this method skips any unknown or not supported bytes.
417+ * This method skips any unknown or not supported characters.
427418 * </p>
428419 *
429420 * @param base64Data
430421 * Byte array containing Base64 data
431- * @return Array containing decoded data.
422+ * @return New array containing decoded data.
432423 * @since 1.21
433424 */
434425 public static byte [] decodeBase64Url (final byte [] base64Data ) {
@@ -439,14 +430,12 @@ public static byte[] decodeBase64Url(final byte[] base64Data) {
439430 * Decodes a URL Safe Base64 String into octets.
440431 * <p>
441432 * Note: implementation of this method is aligned with the Table 2 of RFC 4648.
442- * </p>
443- * <p>
444- * Note 2 this method skips any unknown or not supported characters.
433+ * This method skips any unknown or not supported characters.
445434 * </p>
446435 *
447436 * @param base64String
448437 * String containing Base64 data
449- * @return Array containing decoded data.
438+ * @return New array containing decoded data.
450439 * @since 1.21
451440 */
452441 public static byte [] decodeBase64Url (final String base64String ) {
@@ -628,11 +617,13 @@ public static boolean isArrayByteBase64(final byte[] arrayOctet) {
628617 }
629618
630619 /**
631- * Returns whether or not the {@code octet} is in the base 64 alphabet.
620+ * Tests whether or not the {@code octet} is in the base 64 alphabet.
632621 * <p>
633- * Note: this method threats both characters '+' and '/' and '-' and '_' as valid base64 characters.
622+ * Note: this method threats all characters included within standard base64 and base64url encodings
623+ * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as
624+ * '-' and '_' (url safe base64) characters.
634625 * For enforcing verification against strict standard Base64 or Base64 URL Safe tables,
635- * please use {@code #isBase64Standard} or {@code isBase64Url} methods respectively.
626+ * please use {@link #isBase64Standard} or {@link # isBase64Url} methods respectively.
636627 * </p>
637628 *
638629 * @param octet
@@ -648,9 +639,11 @@ public static boolean isBase64(final byte octet) {
648639 * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the
649640 * method treats whitespace as valid.
650641 * <p>
651- * Note: this method threats both characters '+' and '/' and '-' and '_' as valid base64 characters.
642+ * Note: this method threats all characters included within standard base64 and base64url encodings
643+ * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as
644+ * '-' and '_' (url safe base64) characters.
652645 * For enforcing verification against strict standard Base64 or Base64 URL Safe tables,
653- * please use {@code #isBase64Standard} or {@code isBase64Url} methods respectively.
646+ * please use {@link #isBase64Standard} or {@link # isBase64Url} methods respectively.
654647 * </p>
655648 *
656649 * @param arrayOctet
@@ -672,9 +665,11 @@ public static boolean isBase64(final byte[] arrayOctet) {
672665 * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the
673666 * method treats whitespace as valid.
674667 * <p>
675- * Note: this method threats both characters '+' and '/' and '-' and '_' as valid base64 characters.
668+ * Note: this method threats all characters included within standard base64 and base64url encodings
669+ * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as
670+ * '-' and '_' (url safe base64) characters.
676671 * For enforcing verification against strict standard Base64 or Base64 URL Safe tables,
677- * please use {@code #isBase64Standard} or {@code isBase64Url} methods respectively.
672+ * please use {@link #isBase64Standard} or {@link # isBase64Url} methods respectively.
678673 * </p>
679674 *
680675 * @param base64
@@ -688,7 +683,7 @@ public static boolean isBase64(final String base64) {
688683 }
689684
690685 /**
691- * Returns whether or not the {@code octet} is in the standard base 64 alphabet.
686+ * Tests whether or not the {@code octet} is in the standard base 64 alphabet.
692687 * <p>
693688 * Note: implementation of this method is aligned with the Table 1 of RFC 2045.
694689 * </p>
@@ -744,7 +739,7 @@ public static boolean isBase64Standard(final String base64) {
744739 }
745740
746741 /**
747- * Returns whether or not the {@code octet} is in the url safe base 64 alphabet.
742+ * Tests whether or not the {@code octet} is in the url safe base 64 alphabet.
748743 * <p>
749744 * Note: implementation of this method is aligned with the Table 2 of RFC 4648.
750745 * </p>
0 commit comments