3636 * </ul>
3737 * </p>
3838 * <p>
39- * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode
40- * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).
39+ * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only
40+ * encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252,
41+ * UTF-8, etc).
4142 * </p>
4243 * <p>
4344 * This class is thread-safe.
@@ -98,8 +99,8 @@ public class Base64 extends BaseNCodec {
9899 };
99100
100101 /**
101- * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in
102- * Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64
102+ * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified
103+ * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64
103104 * alphabet but fall within the bounds of the array are translated to -1.
104105 *
105106 * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both
@@ -172,16 +173,16 @@ public Base64() {
172173 /**
173174 * Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode.
174175 * <p>
175- * When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.
176+ * When encoding the line length is 76, the line separator is CRLF, and the encoding table is
177+ * STANDARD_ENCODE_TABLE.
176178 * </p>
177179 *
178180 * <p>
179181 * When decoding all variants are supported.
180182 * </p>
181183 *
182184 * @param urlSafe
183- * if {@code true}, URL-safe encoding is used. In most cases this should be set to
184- * {@code false}.
185+ * if {@code true}, URL-safe encoding is used. In most cases this should be set to {@code false}.
185186 * @since 1.4
186187 */
187188 public Base64 (boolean urlSafe ) {
@@ -202,8 +203,9 @@ public Base64(boolean urlSafe) {
202203 * </p>
203204 *
204205 * @param lineLength
205- * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4).
206- * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
206+ * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
207+ * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when
208+ * decoding.
207209 * @since 1.4
208210 */
209211 public Base64 (int lineLength ) {
@@ -224,8 +226,9 @@ public Base64(int lineLength) {
224226 * </p>
225227 *
226228 * @param lineLength
227- * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4).
228- * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
229+ * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
230+ * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when
231+ * decoding.
229232 * @param lineSeparator
230233 * Each line of encoded data will end with this sequence of bytes.
231234 * @throws IllegalArgumentException
@@ -250,8 +253,9 @@ public Base64(int lineLength, byte[] lineSeparator) {
250253 * </p>
251254 *
252255 * @param lineLength
253- * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4).
254- * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
256+ * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
257+ * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when
258+ * decoding.
255259 * @param lineSeparator
256260 * Each line of encoded data will end with this sequence of bytes.
257261 * @param urlSafe
@@ -315,7 +319,8 @@ public boolean isUrlSafe() {
315319 * Position to start reading data from.
316320 * @param inAvail
317321 * Amount of bytes available from input for encoding.
318- * @param context the context to be used
322+ * @param context
323+ * the context to be used
319324 */
320325 @ Override
321326 void encode (byte [] in , int inPos , int inAvail , Context context ) {
@@ -333,8 +338,10 @@ void encode(byte[] in, int inPos, int inAvail, Context context) {
333338 int savedPos = context .pos ;
334339 switch (context .modulus ) { // 0-2
335340 case 1 : // 8 bits = 6 + 2
336- context .buffer [context .pos ++] = encodeTable [(context .ibitWorkArea >> 2 ) & MASK_6BITS ]; // top 6 bits
337- context .buffer [context .pos ++] = encodeTable [(context .ibitWorkArea << 4 ) & MASK_6BITS ]; // remaining 2
341+ // top 6 bits:
342+ context .buffer [context .pos ++] = encodeTable [(context .ibitWorkArea >> 2 ) & MASK_6BITS ];
343+ // remaining 2:
344+ context .buffer [context .pos ++] = encodeTable [(context .ibitWorkArea << 4 ) & MASK_6BITS ];
338345 // URL-SAFE skips the padding to further reduce size.
339346 if (encodeTable == STANDARD_ENCODE_TABLE ) {
340347 context .buffer [context .pos ++] = PAD ;
@@ -405,7 +412,8 @@ void encode(byte[] in, int inPos, int inAvail, Context context) {
405412 * Position to start reading data from.
406413 * @param inAvail
407414 * Amount of bytes available from input for encoding.
408- * @param context the context to be used
415+ * @param context
416+ * the context to be used
409417 */
410418 @ Override
411419 void decode (byte [] in , int inPos , int inAvail , Context context ) {
0 commit comments