Skip to content

Commit 931bb81

Browse files
committed
Sort members
1 parent cb921ea commit 931bb81

71 files changed

Lines changed: 6618 additions & 6618 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,33 +132,6 @@ public class Base64 extends BaseNCodec {
132132
/** Mask used to extract 2 bits, used when decoding final trailing character. */
133133
private static final int MASK_2BITS = 0x3;
134134

135-
/**
136-
* Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able
137-
* to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch
138-
* between the two modes.
139-
*/
140-
private final byte[] encodeTable;
141-
142-
/** Only one decode table currently; keep for consistency with Base32 code. */
143-
private final byte[] decodeTable = DECODE_TABLE;
144-
145-
/**
146-
* Line separator for encoding. Not used when decoding. Only used if lineLength > 0.
147-
*/
148-
private final byte[] lineSeparator;
149-
150-
/**
151-
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
152-
* {@code decodeSize = 3 + lineSeparator.length;}
153-
*/
154-
private final int decodeSize;
155-
156-
/**
157-
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
158-
* {@code encodeSize = 4 + lineSeparator.length;}
159-
*/
160-
private final int encodeSize;
161-
162135
/**
163136
* Decodes Base64 data into octets.
164137
* <p>
@@ -441,6 +414,33 @@ static byte[] toIntegerBytes(final BigInteger bigInt) {
441414
return resizedBytes;
442415
}
443416

417+
/**
418+
* Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able
419+
* to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch
420+
* between the two modes.
421+
*/
422+
private final byte[] encodeTable;
423+
424+
/** Only one decode table currently; keep for consistency with Base32 code. */
425+
private final byte[] decodeTable = DECODE_TABLE;
426+
427+
/**
428+
* Line separator for encoding. Not used when decoding. Only used if lineLength &gt; 0.
429+
*/
430+
private final byte[] lineSeparator;
431+
432+
/**
433+
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
434+
* {@code decodeSize = 3 + lineSeparator.length;}
435+
*/
436+
private final int decodeSize;
437+
438+
/**
439+
* Convenience variable to help us determine when our buffer is going to run out of room and needs resizing.
440+
* {@code encodeSize = 4 + lineSeparator.length;}
441+
*/
442+
private final int encodeSize;
443+
444444
/**
445445
* Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
446446
* <p>

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

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,74 @@
5151
*/
5252
public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
5353

54+
/**
55+
* Holds thread context so classes can be thread-safe.
56+
*
57+
* This class is not itself thread-safe; each thread must allocate its own copy.
58+
*
59+
* @since 1.7
60+
*/
61+
static class Context {
62+
63+
/**
64+
* Placeholder for the bytes we're dealing with for our based logic.
65+
* Bitwise operations store and extract the encoding or decoding from this variable.
66+
*/
67+
int ibitWorkArea;
68+
69+
/**
70+
* Placeholder for the bytes we're dealing with for our based logic.
71+
* Bitwise operations store and extract the encoding or decoding from this variable.
72+
*/
73+
long lbitWorkArea;
74+
75+
/**
76+
* Buffer for streaming.
77+
*/
78+
byte[] buffer;
79+
80+
/**
81+
* Position where next character should be written in the buffer.
82+
*/
83+
int pos;
84+
85+
/**
86+
* Position where next character should be read from the buffer.
87+
*/
88+
int readPos;
89+
90+
/**
91+
* Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless,
92+
* and must be thrown away.
93+
*/
94+
boolean eof;
95+
96+
/**
97+
* Variable tracks how many characters have been written to the current line. Only used when encoding. We use
98+
* it to make sure each encoded line never goes beyond lineLength (if lineLength &gt; 0).
99+
*/
100+
int currentLinePos;
101+
102+
/**
103+
* Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This
104+
* variable helps track that.
105+
*/
106+
int modulus;
107+
108+
/**
109+
* Returns a String useful for debugging (especially within a debugger.)
110+
*
111+
* @return a String useful for debugging.
112+
*/
113+
@SuppressWarnings("boxing") // OK to ignore boxing here
114+
@Override
115+
public String toString() {
116+
return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " +
117+
"modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer),
118+
currentLinePos, eof, ibitWorkArea, lbitWorkArea, modulus, pos, readPos);
119+
}
120+
}
121+
54122
/**
55123
* EOF
56124
*
@@ -123,122 +191,6 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
123191
*/
124192
static final byte[] CHUNK_SEPARATOR = {'\r', '\n'};
125193

126-
/**
127-
* @deprecated Use {@link #pad}. Will be removed in 2.0.
128-
*/
129-
@Deprecated
130-
protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later
131-
132-
/** Pad byte. Instance variable just in case it needs to vary later. */
133-
protected final byte pad;
134-
135-
/** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */
136-
private final int unencodedBlockSize;
137-
138-
/** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */
139-
private final int encodedBlockSize;
140-
141-
/**
142-
* Chunksize for encoding. Not used when decoding.
143-
* A value of zero or less implies no chunking of the encoded data.
144-
* Rounded down to the nearest multiple of encodedBlockSize.
145-
*/
146-
protected final int lineLength;
147-
148-
/**
149-
* Size of chunk separator. Not used unless {@link #lineLength} &gt; 0.
150-
*/
151-
private final int chunkSeparatorLength;
152-
153-
/**
154-
* Defines the decoding behavior when the input bytes contain leftover trailing bits that
155-
* cannot be created by a valid encoding. These can be bits that are unused from the final
156-
* character or entire characters. The default mode is lenient decoding. Set this to
157-
* {@code true} to enable strict decoding.
158-
* <ul>
159-
* <li>Lenient: Any trailing bits are composed into 8-bit bytes where possible.
160-
* The remainder are discarded.
161-
* <li>Strict: The decoding will raise an {@link IllegalArgumentException} if trailing bits
162-
* are not part of a valid encoding. Any unused bits from the final character must
163-
* be zero. Impossible counts of entire final characters are not allowed.
164-
* </ul>
165-
* <p>
166-
* When strict decoding is enabled it is expected that the decoded bytes will be re-encoded
167-
* to a byte array that matches the original, i.e. no changes occur on the final
168-
* character. This requires that the input bytes use the same padding and alphabet
169-
* as the encoder.
170-
* </p>
171-
*/
172-
private final CodecPolicy decodingPolicy;
173-
174-
/**
175-
* Holds thread context so classes can be thread-safe.
176-
*
177-
* This class is not itself thread-safe; each thread must allocate its own copy.
178-
*
179-
* @since 1.7
180-
*/
181-
static class Context {
182-
183-
/**
184-
* Placeholder for the bytes we're dealing with for our based logic.
185-
* Bitwise operations store and extract the encoding or decoding from this variable.
186-
*/
187-
int ibitWorkArea;
188-
189-
/**
190-
* Placeholder for the bytes we're dealing with for our based logic.
191-
* Bitwise operations store and extract the encoding or decoding from this variable.
192-
*/
193-
long lbitWorkArea;
194-
195-
/**
196-
* Buffer for streaming.
197-
*/
198-
byte[] buffer;
199-
200-
/**
201-
* Position where next character should be written in the buffer.
202-
*/
203-
int pos;
204-
205-
/**
206-
* Position where next character should be read from the buffer.
207-
*/
208-
int readPos;
209-
210-
/**
211-
* Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless,
212-
* and must be thrown away.
213-
*/
214-
boolean eof;
215-
216-
/**
217-
* Variable tracks how many characters have been written to the current line. Only used when encoding. We use
218-
* it to make sure each encoded line never goes beyond lineLength (if lineLength &gt; 0).
219-
*/
220-
int currentLinePos;
221-
222-
/**
223-
* Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This
224-
* variable helps track that.
225-
*/
226-
int modulus;
227-
228-
/**
229-
* Returns a String useful for debugging (especially within a debugger.)
230-
*
231-
* @return a String useful for debugging.
232-
*/
233-
@SuppressWarnings("boxing") // OK to ignore boxing here
234-
@Override
235-
public String toString() {
236-
return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " +
237-
"modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer),
238-
currentLinePos, eof, ibitWorkArea, lbitWorkArea, modulus, pos, readPos);
239-
}
240-
}
241-
242194
/**
243195
* Create a positive capacity at least as large the minimum required capacity.
244196
* If the minimum capacity is negative then this throws an OutOfMemoryError as no array
@@ -311,6 +263,54 @@ private static byte[] resizeBuffer(final Context context, final int minCapacity)
311263
return b;
312264
}
313265

266+
/**
267+
* @deprecated Use {@link #pad}. Will be removed in 2.0.
268+
*/
269+
@Deprecated
270+
protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later
271+
272+
/** Pad byte. Instance variable just in case it needs to vary later. */
273+
protected final byte pad;
274+
275+
/** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */
276+
private final int unencodedBlockSize;
277+
278+
/** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */
279+
private final int encodedBlockSize;
280+
281+
/**
282+
* Chunksize for encoding. Not used when decoding.
283+
* A value of zero or less implies no chunking of the encoded data.
284+
* Rounded down to the nearest multiple of encodedBlockSize.
285+
*/
286+
protected final int lineLength;
287+
288+
/**
289+
* Size of chunk separator. Not used unless {@link #lineLength} &gt; 0.
290+
*/
291+
private final int chunkSeparatorLength;
292+
293+
/**
294+
* Defines the decoding behavior when the input bytes contain leftover trailing bits that
295+
* cannot be created by a valid encoding. These can be bits that are unused from the final
296+
* character or entire characters. The default mode is lenient decoding. Set this to
297+
* {@code true} to enable strict decoding.
298+
* <ul>
299+
* <li>Lenient: Any trailing bits are composed into 8-bit bytes where possible.
300+
* The remainder are discarded.
301+
* <li>Strict: The decoding will raise an {@link IllegalArgumentException} if trailing bits
302+
* are not part of a valid encoding. Any unused bits from the final character must
303+
* be zero. Impossible counts of entire final characters are not allowed.
304+
* </ul>
305+
* <p>
306+
* When strict decoding is enabled it is expected that the decoded bytes will be re-encoded
307+
* to a byte array that matches the original, i.e. no changes occur on the final
308+
* character. This requires that the input bytes use the same padding and alphabet
309+
* as the encoder.
310+
* </p>
311+
*/
312+
private final CodecPolicy decodingPolicy;
313+
314314
/**
315315
* Note {@code lineLength} is rounded down to the nearest multiple of the encoded block size.
316316
* If {@code chunkSeparatorLength} is zero, then chunking is disabled.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public class Hex implements BinaryEncoder, BinaryDecoder {
6363
private static final char[] DIGITS_UPPER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
6464
'E', 'F' };
6565

66-
private final Charset charset;
67-
6866
/**
6967
* Converts an array of characters representing hexadecimal values into an array of bytes of those same values. The
7068
* returned array will be half the length of the passed array, as it takes two characters to represent any given
@@ -373,6 +371,8 @@ protected static int toDigit(final char ch, final int index) throws DecoderExcep
373371
return digit;
374372
}
375373

374+
private final Charset charset;
375+
376376
/**
377377
* Creates a new codec with the default charset name {@link #DEFAULT_CHARSET}
378378
*/

src/main/java/org/apache/commons/codec/cli/Digest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
*/
3636
public class Digest {
3737

38-
private final String algorithm;
39-
private final String[] args;
40-
private final String[] inputs;
41-
4238
/**
4339
* Runs the digest algorithm in {@code args[0]} on the file in {@code args[1]}. If there is no {@code args[1]}, use
4440
* standard input.
@@ -56,6 +52,10 @@ public class Digest {
5652
public static void main(final String[] args) throws IOException {
5753
new Digest(args).run();
5854
}
55+
private final String algorithm;
56+
private final String[] args;
57+
58+
private final String[] inputs;
5959

6060
private Digest(final String[] args) {
6161
if (args == null) {
@@ -101,14 +101,6 @@ private void run() throws IOException {
101101
}
102102
}
103103

104-
private void run(final String[] digestAlgorithms) throws IOException {
105-
for (final String messageDigestAlgorithm : digestAlgorithms) {
106-
if (DigestUtils.isAvailable(messageDigestAlgorithm)) {
107-
run(messageDigestAlgorithm + " ", messageDigestAlgorithm);
108-
}
109-
}
110-
}
111-
112104
private void run(final String prefix, final MessageDigest messageDigest) throws IOException {
113105
if (inputs == null) {
114106
println(prefix, DigestUtils.digest(messageDigest, System.in));
@@ -143,6 +135,14 @@ private void run(final String prefix, final String messageDigestAlgorithm) throw
143135
run(prefix, DigestUtils.getDigest(messageDigestAlgorithm));
144136
}
145137

138+
private void run(final String[] digestAlgorithms) throws IOException {
139+
for (final String messageDigestAlgorithm : digestAlgorithms) {
140+
if (DigestUtils.isAvailable(messageDigestAlgorithm)) {
141+
run(messageDigestAlgorithm + " ", messageDigestAlgorithm);
142+
}
143+
}
144+
}
145+
146146
@Override
147147
public String toString() {
148148
return String.format("%s %s", super.toString(), Arrays.toString(args));

0 commit comments

Comments
 (0)