Skip to content

Commit c6b9e15

Browse files
committed
Use Checkstyle: WhitespaceAfter
- Longer lines sometimes - Format some files
1 parent 3c5913a commit c6b9e15

27 files changed

Lines changed: 995 additions & 1048 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424
<parent>
2525
<groupId>org.apache.commons</groupId>
2626
<artifactId>commons-parent</artifactId>
27-
<version>64</version>
27+
<version>65</version>
2828
</parent>
2929
<groupId>commons-codec</groupId>
3030
<artifactId>commons-codec</artifactId>

src/conf/checkstyle.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ limitations under the License.
6060
</module>
6161

6262
<module name="TreeWalker">
63+
<module name="WhitespaceAfter" />
6364
<module name="ExplicitInitializationCheck" />
6465
<module name="OperatorWrap">
6566
<property name="option" value="eol" />

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

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
* This class is thread-safe.
2727
* </p>
2828
* <p>
29-
* This implementation strictly follows RFC 4648, and as such unlike
30-
* the {@link Base32} and {@link Base64} implementations,
31-
* it does not ignore invalid alphabet characters or whitespace,
32-
* neither does it offer chunking or padding characters.
29+
* This implementation strictly follows RFC 4648, and as such unlike the {@link Base32} and {@link Base64} implementations, it does not ignore invalid alphabet
30+
* characters or whitespace, neither does it offer chunking or padding characters.
3331
* </p>
3432
* <p>
35-
* The only additional feature above those specified in RFC 4648
36-
* is support for working with a lower-case alphabet in addition
37-
* to the default upper-case alphabet.
33+
* The only additional feature above those specified in RFC 4648 is support for working with a lower-case alphabet in addition to the default upper-case
34+
* alphabet.
3835
* </p>
3936
*
4037
* @see <a href="https://tools.ietf.org/html/rfc4648#section-8">RFC 4648 - 8. Base 16 Encoding</a>
@@ -44,19 +41,17 @@
4441
public class Base16 extends BaseNCodec {
4542

4643
/**
47-
* BASE16 characters are 4 bits in length.
48-
* They are formed by taking an 8-bit group,
49-
* which is converted into two BASE16 characters.
44+
* BASE16 characters are 4 bits in length. They are formed by taking an 8-bit group, which is converted into two BASE16 characters.
5045
*/
5146
private static final int BITS_PER_ENCODED_BYTE = 4;
5247
private static final int BYTES_PER_ENCODED_BLOCK = 2;
5348
private static final int BYTES_PER_UNENCODED_BLOCK = 1;
5449

5550
/**
56-
* This array is a lookup table that translates Unicode characters drawn from the "Base16 Alphabet" (as specified
57-
* in Table 5 of RFC 4648) into their 4-bit positive integer equivalents. Characters that are not in the Base16
58-
* alphabet but fall within the bounds of the array are translated to -1.
51+
* This array is a lookup table that translates Unicode characters drawn from the "Base16 Alphabet" (as specified in Table 5 of RFC 4648) into their 4-bit
52+
* positive integer equivalents. Characters that are not in the Base16 alphabet but fall within the bounds of the array are translated to -1.
5953
*/
54+
// @formatter:off
6055
private static final byte[] UPPER_CASE_DECODE_TABLE = {
6156
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
6257
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f
@@ -65,21 +60,24 @@ public class Base16 extends BaseNCodec {
6560
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 30-3f 0-9
6661
-1, 10, 11, 12, 13, 14, 15 // 40-46 A-F
6762
};
63+
// @formatter:on
6864

6965
/**
70-
* This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet"
71-
* equivalents as specified in Table 5 of RFC 4648.
66+
* This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" equivalents as specified in Table 5 of RFC
67+
* 4648.
7268
*/
69+
// @formatter:off
7370
private static final byte[] UPPER_CASE_ENCODE_TABLE = {
7471
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
7572
'A', 'B', 'C', 'D', 'E', 'F'
7673
};
74+
// @formatter:on
7775

7876
/**
79-
* This array is a lookup table that translates Unicode characters drawn from the a lower-case "Base16 Alphabet"
80-
* into their 4-bit positive integer equivalents. Characters that are not in the Base16
81-
* alphabet but fall within the bounds of the array are translated to -1.
77+
* This array is a lookup table that translates Unicode characters drawn from the a lower-case "Base16 Alphabet" into their 4-bit positive integer
78+
* equivalents. Characters that are not in the Base16 alphabet but fall within the bounds of the array are translated to -1.
8279
*/
80+
// @formatter:off
8381
private static final byte[] LOWER_CASE_DECODE_TABLE = {
8482
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
8583
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f
@@ -90,15 +88,17 @@ public class Base16 extends BaseNCodec {
9088
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 50-5f
9189
-1, 10, 11, 12, 13, 14, 15 // 60-66 a-f
9290
};
91+
// @formatter:on
9392

9493
/**
95-
* This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet"
96-
* lower-case equivalents.
94+
* This array is a lookup table that translates 4-bit positive integer index values into their "Base16 Alphabet" lower-case equivalents.
9795
*/
96+
// @formatter:off
9897
private static final byte[] LOWER_CASE_ENCODE_TABLE = {
9998
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
10099
'a', 'b', 'c', 'd', 'e', 'f'
101100
};
101+
// @formatter:on
102102

103103
/** Mask used to extract 4 bits, used when decoding character. */
104104
private static final int MASK_4BITS = 0x0f;
@@ -132,12 +132,11 @@ public Base16(final boolean lowerCase) {
132132
/**
133133
* Creates a Base16 codec used for decoding and encoding.
134134
*
135-
* @param lowerCase if {@code true} then use a lower-case Base16 alphabet.
135+
* @param lowerCase if {@code true} then use a lower-case Base16 alphabet.
136136
* @param decodingPolicy Decoding policy.
137137
*/
138138
public Base16(final boolean lowerCase, final CodecPolicy decodingPolicy) {
139-
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, 0, 0,
140-
PAD_DEFAULT, decodingPolicy);
139+
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, 0, 0, PAD_DEFAULT, decodingPolicy);
141140
if (lowerCase) {
142141
this.encodeTable = LOWER_CASE_ENCODE_TABLE;
143142
this.decodeTable = LOWER_CASE_DECODE_TABLE;
@@ -179,7 +178,7 @@ void decode(final byte[] data, int offset, final int length, final Context conte
179178
result = context.ibitWorkArea - 1 << BITS_PER_ENCODED_BYTE;
180179
result |= decodeOctet(data[offset++]);
181180

182-
buffer[context.pos++] = (byte)result;
181+
buffer[context.pos++] = (byte) result;
183182

184183
// reset to empty-value for next invocation!
185184
context.ibitWorkArea = 0;
@@ -189,7 +188,7 @@ void decode(final byte[] data, int offset, final int length, final Context conte
189188
while (offset < loopEnd) {
190189
result = decodeOctet(data[offset++]) << BITS_PER_ENCODED_BYTE;
191190
result |= decodeOctet(data[offset++]);
192-
buffer[context.pos++] = (byte)result;
191+
buffer[context.pos++] = (byte) result;
193192
}
194193

195194
// we have one char of a hex-pair left over
@@ -206,7 +205,7 @@ private int decodeOctet(final byte octet) {
206205
}
207206

208207
if (decoded == -1) {
209-
throw new IllegalArgumentException("Invalid octet in encoded value: " + (int)octet);
208+
throw new IllegalArgumentException("Invalid octet in encoded value: " + (int) octet);
210209
}
211210

212211
return decoded;
@@ -253,15 +252,13 @@ public boolean isInAlphabet(final byte octet) {
253252
}
254253

255254
/**
256-
* Validates whether decoding allows an entire final trailing character that cannot be
257-
* used for a complete byte.
255+
* Validates whether decoding allows an entire final trailing character that cannot be used for a complete byte.
258256
*
259257
* @throws IllegalArgumentException if strict decoding is enabled
260258
*/
261259
private void validateTrailingCharacter() {
262260
if (isStrictDecoding()) {
263-
throw new IllegalArgumentException("Strict decoding: Last encoded character is a valid base 16 alphabet" +
264-
"character but not a possible encoding. " +
261+
throw new IllegalArgumentException("Strict decoding: Last encoded character is a valid base 16 alphabet character but not a possible encoding. " +
265262
"Decoding requires at least two characters to create one byte.");
266263
}
267264
}

0 commit comments

Comments
 (0)