Author: ggregory
Date: Mon Jan 7 16:08:05 2013
New Revision: 1429868
URL: http://svn.apache.org/viewvc?rev=1429868&view=rev
Log:
Use final where possible.
Modified:
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/Charsets.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/DecoderException.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/StringEncoderComparator.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Hex.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/StringUtils.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/B64.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Crypt.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/AbstractCaverphone.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Caverphone.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Caverphone1.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Caverphone2.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/ColognePhonetic.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Metaphone.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Nysiis.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/Soundex.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/SoundexUtils.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Lang.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Languages.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/NameType.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/Rule.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/language/bm/RuleType.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/BCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/URLCodec.java
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/net/Utils.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/BinaryEncoderAbstractTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/EncoderExceptionTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/StringEncoderAbstractTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/StringEncoderComparatorTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base32TestData.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64TestData.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/B64Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/CryptTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone1Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/Caverphone2Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/ColognePhoneticTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphone2Test.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/DoubleMetaphoneTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/MetaphoneTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/NysiisTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/RefinedSoundexTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/SoundexTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineRegressionTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/PhoneticEngineTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/language/bm/RuleTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/BCodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QCodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/Charsets.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/Charsets.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/Charsets.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/Charsets.java Mon Jan 7 16:08:05 2013
@@ -70,7 +70,7 @@ public class Charsets {
* A charset or null.
* @return the given Charset or the default Charset if the given Charset is null
*/
- public static Charset toCharset(Charset charset) {
+ public static Charset toCharset(final Charset charset) {
return charset == null ? Charset.defaultCharset() : charset;
}
@@ -83,7 +83,7 @@ public class Charsets {
* @throws java.nio.charset.UnsupportedCharsetException
* If the named charset is unavailable
*/
- public static Charset toCharset(String charset) {
+ public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/DecoderException.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/DecoderException.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/DecoderException.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/DecoderException.java Mon Jan 7 16:08:05 2013
@@ -49,7 +49,7 @@ public class DecoderException extends Ex
* @param message
* The detail message which is saved for later retrieval by the {@link #getMessage()} method.
*/
- public DecoderException(String message) {
+ public DecoderException(final String message) {
super(message);
}
@@ -66,7 +66,7 @@ public class DecoderException extends Ex
* value is permitted, and indicates that the cause is nonexistent or unknown.
* @since 1.4
*/
- public DecoderException(String message, Throwable cause) {
+ public DecoderException(final String message, final Throwable cause) {
super(message, cause);
}
@@ -80,7 +80,7 @@ public class DecoderException extends Ex
* value is permitted, and indicates that the cause is nonexistent or unknown.
* @since 1.4
*/
- public DecoderException(Throwable cause) {
+ public DecoderException(final Throwable cause) {
super(cause);
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/StringEncoderComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/StringEncoderComparator.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/StringEncoderComparator.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/StringEncoderComparator.java Mon Jan 7 16:08:05 2013
@@ -52,7 +52,7 @@ public class StringEncoderComparator imp
* @param stringEncoder
* the StringEncoder used for comparisons.
*/
- public StringEncoderComparator(StringEncoder stringEncoder) {
+ public StringEncoderComparator(final StringEncoder stringEncoder) {
this.stringEncoder = stringEncoder;
}
@@ -70,15 +70,15 @@ public class StringEncoderComparator imp
* @see Comparable
*/
@Override
- public int compare(Object o1, Object o2) {
+ public int compare(final Object o1, final Object o2) {
int compareCode = 0;
try {
- Comparable s1 = (Comparable) this.stringEncoder.encode(o1);
- Comparable s2 = (Comparable) this.stringEncoder.encode(o2);
+ final Comparable s1 = (Comparable) this.stringEncoder.encode(o1);
+ final Comparable s2 = (Comparable) this.stringEncoder.encode(o2);
compareCode = s1.compareTo(s2);
- } catch (EncoderException ee) {
+ } catch (final EncoderException ee) {
compareCode = 0;
}
return compareCode;
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java Mon Jan 7 16:08:05 2013
@@ -166,7 +166,7 @@ public class Base32 extends BaseNCodec {
* </p>
* @param useHex if {@code true} then use Base32 Hex alphabet
*/
- public Base32(boolean useHex) {
+ public Base32(final boolean useHex) {
this(0, null, useHex);
}
@@ -181,7 +181,7 @@ public class Base32 extends BaseNCodec {
* 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when
* decoding.
*/
- public Base32(int lineLength) {
+ public Base32(final int lineLength) {
this(lineLength, CHUNK_SEPARATOR);
}
@@ -203,7 +203,7 @@ public class Base32 extends BaseNCodec {
* @throws IllegalArgumentException
* The provided lineSeparator included some Base32 characters. That's not going to work!
*/
- public Base32(int lineLength, byte[] lineSeparator) {
+ public Base32(final int lineLength, final byte[] lineSeparator) {
this(lineLength, lineSeparator, false);
}
@@ -228,7 +228,7 @@ public class Base32 extends BaseNCodec {
* The provided lineSeparator included some Base32 characters. That's not going to work! Or the
* lineLength > 0 and lineSeparator is null.
*/
- public Base32(int lineLength, byte[] lineSeparator, boolean useHex) {
+ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex) {
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK,
lineLength,
lineSeparator == null ? 0 : lineSeparator.length);
@@ -245,7 +245,7 @@ public class Base32 extends BaseNCodec {
}
// Must be done after initializing the tables
if (containsAlphabetOrPad(lineSeparator)) {
- String sep = StringUtils.newStringUtf8(lineSeparator);
+ final String sep = StringUtils.newStringUtf8(lineSeparator);
throw new IllegalArgumentException("lineSeparator must not contain Base32 characters: [" + sep + "]");
}
this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length;
@@ -281,7 +281,7 @@ public class Base32 extends BaseNCodec {
* Output is written to {@link Context#buffer} as 8-bit octets, using {@link Context#pos} as the buffer position
*/
@Override
- void decode(byte[] in, int inPos, int inAvail, Context context) { // package protected for access from I/O streams
+ void decode(final byte[] in, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams
if (context.eof) {
return;
}
@@ -375,7 +375,7 @@ public class Base32 extends BaseNCodec {
* @param context the context to be used
*/
@Override
- void encode(byte[] in, int inPos, int inAvail, Context context) { // package protected for access from I/O streams
+ void encode(final byte[] in, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams
if (context.eof) {
return;
}
@@ -477,7 +477,7 @@ public class Base32 extends BaseNCodec {
* @return {@code true} if the value is defined in the the Base32 alphabet {@code false} otherwise.
*/
@Override
- public boolean isInAlphabet(byte octet) {
+ public boolean isInAlphabet(final byte octet) {
return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1;
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java Mon Jan 7 16:08:05 2013
@@ -44,7 +44,7 @@ public class Base32InputStream extends B
* @param in
* InputStream to wrap.
*/
- public Base32InputStream(InputStream in) {
+ public Base32InputStream(final InputStream in) {
this(in, false);
}
@@ -57,7 +57,7 @@ public class Base32InputStream extends B
* @param doEncode
* true if we should encode all data read from us, false if we should decode.
*/
- public Base32InputStream(InputStream in, boolean doEncode) {
+ public Base32InputStream(final InputStream in, final boolean doEncode) {
super(in, new Base32(false), doEncode);
}
@@ -77,7 +77,7 @@ public class Base32InputStream extends B
* If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n).
* If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored.
*/
- public Base32InputStream(InputStream in, boolean doEncode, int lineLength, byte[] lineSeparator) {
+ public Base32InputStream(final InputStream in, final boolean doEncode, final int lineLength, final byte[] lineSeparator) {
super(in, new Base32(lineLength, lineSeparator), doEncode);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java Mon Jan 7 16:08:05 2013
@@ -44,7 +44,7 @@ public class Base32OutputStream extends
* @param out
* OutputStream to wrap.
*/
- public Base32OutputStream(OutputStream out) {
+ public Base32OutputStream(final OutputStream out) {
this(out, true);
}
@@ -57,7 +57,7 @@ public class Base32OutputStream extends
* @param doEncode
* true if we should encode all data written to us, false if we should decode.
*/
- public Base32OutputStream(OutputStream out, boolean doEncode) {
+ public Base32OutputStream(final OutputStream out, final boolean doEncode) {
super(out, new Base32(false), doEncode);
}
@@ -77,7 +77,7 @@ public class Base32OutputStream extends
* If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n).
* If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored.
*/
- public Base32OutputStream(OutputStream out, boolean doEncode, int lineLength, byte[] lineSeparator) {
+ public Base32OutputStream(final OutputStream out, final boolean doEncode, final int lineLength, final byte[] lineSeparator) {
super(out, new Base32(lineLength, lineSeparator), doEncode);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java Mon Jan 7 16:08:05 2013
@@ -185,7 +185,7 @@ public class Base64 extends BaseNCodec {
* if {@code true}, URL-safe encoding is used. In most cases this should be set to {@code false}.
* @since 1.4
*/
- public Base64(boolean urlSafe) {
+ public Base64(final boolean urlSafe) {
this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe);
}
@@ -208,7 +208,7 @@ public class Base64 extends BaseNCodec {
* decoding.
* @since 1.4
*/
- public Base64(int lineLength) {
+ public Base64(final int lineLength) {
this(lineLength, CHUNK_SEPARATOR);
}
@@ -235,7 +235,7 @@ public class Base64 extends BaseNCodec {
* Thrown when the provided lineSeparator included some base64 characters.
* @since 1.4
*/
- public Base64(int lineLength, byte[] lineSeparator) {
+ public Base64(final int lineLength, final byte[] lineSeparator) {
this(lineLength, lineSeparator, false);
}
@@ -266,7 +266,7 @@ public class Base64 extends BaseNCodec {
* The provided lineSeparator included some base64 characters. That's not going to work!
* @since 1.4
*/
- public Base64(int lineLength, byte[] lineSeparator, boolean urlSafe) {
+ public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) {
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK,
lineLength,
lineSeparator == null ? 0 : lineSeparator.length);
@@ -274,7 +274,7 @@ public class Base64 extends BaseNCodec {
// @see test case Base64Test.testConstructors()
if (lineSeparator != null) {
if (containsAlphabetOrPad(lineSeparator)) {
- String sep = StringUtils.newStringUtf8(lineSeparator);
+ final String sep = StringUtils.newStringUtf8(lineSeparator);
throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]");
}
if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE
@@ -325,7 +325,7 @@ public class Base64 extends BaseNCodec {
* the context to be used
*/
@Override
- void encode(byte[] in, int inPos, int inAvail, Context context) {
+ void encode(final byte[] in, int inPos, final int inAvail, final Context context) {
if (context.eof) {
return;
}
@@ -422,7 +422,7 @@ public class Base64 extends BaseNCodec {
* the context to be used
*/
@Override
- void decode(byte[] in, int inPos, int inAvail, Context context) {
+ void decode(final byte[] in, int inPos, final int inAvail, final Context context) {
if (context.eof) {
return;
}
@@ -491,7 +491,7 @@ public class Base64 extends BaseNCodec {
* @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0.
*/
@Deprecated
- public static boolean isArrayByteBase64(byte[] arrayOctet) {
+ public static boolean isArrayByteBase64(final byte[] arrayOctet) {
return isBase64(arrayOctet);
}
@@ -503,7 +503,7 @@ public class Base64 extends BaseNCodec {
* @return {@code true} if the value is defined in the the base 64 alphabet, {@code false} otherwise.
* @since 1.4
*/
- public static boolean isBase64(byte octet) {
+ public static boolean isBase64(final byte octet) {
return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1);
}
@@ -517,7 +517,7 @@ public class Base64 extends BaseNCodec {
* the String is empty; {@code false}, otherwise
* @since 1.5
*/
- public static boolean isBase64(String base64) {
+ public static boolean isBase64(final String base64) {
return isBase64(StringUtils.getBytesUtf8(base64));
}
@@ -531,7 +531,7 @@ public class Base64 extends BaseNCodec {
* {@code false}, otherwise
* @since 1.5
*/
- public static boolean isBase64(byte[] arrayOctet) {
+ public static boolean isBase64(final byte[] arrayOctet) {
for (int i = 0; i < arrayOctet.length; i++) {
if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) {
return false;
@@ -547,7 +547,7 @@ public class Base64 extends BaseNCodec {
* binary data to encode
* @return byte[] containing Base64 characters in their UTF-8 representation.
*/
- public static byte[] encodeBase64(byte[] binaryData) {
+ public static byte[] encodeBase64(final byte[] binaryData) {
return encodeBase64(binaryData, false);
}
@@ -562,7 +562,7 @@ public class Base64 extends BaseNCodec {
* @return String containing Base64 characters.
* @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not).
*/
- public static String encodeBase64String(byte[] binaryData) {
+ public static String encodeBase64String(final byte[] binaryData) {
return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
}
@@ -575,7 +575,7 @@ public class Base64 extends BaseNCodec {
* @return byte[] containing Base64 characters in their UTF-8 representation.
* @since 1.4
*/
- public static byte[] encodeBase64URLSafe(byte[] binaryData) {
+ public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
return encodeBase64(binaryData, false, true);
}
@@ -588,7 +588,7 @@ public class Base64 extends BaseNCodec {
* @return String containing Base64 characters
* @since 1.4
*/
- public static String encodeBase64URLSafeString(byte[] binaryData) {
+ public static String encodeBase64URLSafeString(final byte[] binaryData) {
return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true));
}
@@ -599,7 +599,7 @@ public class Base64 extends BaseNCodec {
* binary data to encode
* @return Base64 characters chunked in 76 character blocks
*/
- public static byte[] encodeBase64Chunked(byte[] binaryData) {
+ public static byte[] encodeBase64Chunked(final byte[] binaryData) {
return encodeBase64(binaryData, true);
}
@@ -614,7 +614,7 @@ public class Base64 extends BaseNCodec {
* @throws IllegalArgumentException
* Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}
*/
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
+ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) {
return encodeBase64(binaryData, isChunked, false);
}
@@ -633,7 +633,7 @@ public class Base64 extends BaseNCodec {
* Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}
* @since 1.4
*/
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe) {
+ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) {
return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE);
}
@@ -654,15 +654,15 @@ public class Base64 extends BaseNCodec {
* Thrown when the input array needs an output array bigger than maxResultSize
* @since 1.4
*/
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe, int maxResultSize) {
+ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, final int maxResultSize) {
if (binaryData == null || binaryData.length == 0) {
return binaryData;
}
// Create this so can use the super-class method
// Also ensures that the same roundings are performed by the ctor and the code
- Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe);
- long len = b64.getEncodedLength(binaryData);
+ final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe);
+ final long len = b64.getEncodedLength(binaryData);
if (len > maxResultSize) {
throw new IllegalArgumentException("Input array too big, the output array would be bigger (" +
len +
@@ -681,7 +681,7 @@ public class Base64 extends BaseNCodec {
* @return Array containing decoded data.
* @since 1.4
*/
- public static byte[] decodeBase64(String base64String) {
+ public static byte[] decodeBase64(final String base64String) {
return new Base64().decode(base64String);
}
@@ -692,7 +692,7 @@ public class Base64 extends BaseNCodec {
* Byte array containing Base64 data
* @return Array containing decoded data.
*/
- public static byte[] decodeBase64(byte[] base64Data) {
+ public static byte[] decodeBase64(final byte[] base64Data) {
return new Base64().decode(base64Data);
}
@@ -707,7 +707,7 @@ public class Base64 extends BaseNCodec {
* @return A BigInteger
* @since 1.4
*/
- public static BigInteger decodeInteger(byte[] pArray) {
+ public static BigInteger decodeInteger(final byte[] pArray) {
return new BigInteger(1, decodeBase64(pArray));
}
@@ -721,7 +721,7 @@ public class Base64 extends BaseNCodec {
* if null is passed in
* @since 1.4
*/
- public static byte[] encodeInteger(BigInteger bigInt) {
+ public static byte[] encodeInteger(final BigInteger bigInt) {
if (bigInt == null) {
throw new NullPointerException("encodeInteger called with null parameter");
}
@@ -735,11 +735,11 @@ public class Base64 extends BaseNCodec {
* <code>BigInteger</code> to be converted
* @return a byte array representation of the BigInteger parameter
*/
- static byte[] toIntegerBytes(BigInteger bigInt) {
+ static byte[] toIntegerBytes(final BigInteger bigInt) {
int bitlen = bigInt.bitLength();
// round bitlen
bitlen = ((bitlen + 7) >> 3) << 3;
- byte[] bigBytes = bigInt.toByteArray();
+ final byte[] bigBytes = bigInt.toByteArray();
if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) {
return bigBytes;
@@ -753,8 +753,8 @@ public class Base64 extends BaseNCodec {
startSrc = 1;
len--;
}
- int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec
- byte[] resizedBytes = new byte[bitlen / 8];
+ final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec
+ final byte[] resizedBytes = new byte[bitlen / 8];
System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len);
return resizedBytes;
}
@@ -767,7 +767,7 @@ public class Base64 extends BaseNCodec {
* @return {@code true} if the value is defined in the the Base64 alphabet {@code false} otherwise.
*/
@Override
- protected boolean isInAlphabet(byte octet) {
+ protected boolean isInAlphabet(final byte octet) {
return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1;
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java Mon Jan 7 16:08:05 2013
@@ -48,7 +48,7 @@ public class Base64InputStream extends B
* @param in
* InputStream to wrap.
*/
- public Base64InputStream(InputStream in) {
+ public Base64InputStream(final InputStream in) {
this(in, false);
}
@@ -61,7 +61,7 @@ public class Base64InputStream extends B
* @param doEncode
* true if we should encode all data read from us, false if we should decode.
*/
- public Base64InputStream(InputStream in, boolean doEncode) {
+ public Base64InputStream(final InputStream in, final boolean doEncode) {
super(in, new Base64(false), doEncode);
}
@@ -81,7 +81,7 @@ public class Base64InputStream extends B
* If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n).
* If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored.
*/
- public Base64InputStream(InputStream in, boolean doEncode, int lineLength, byte[] lineSeparator) {
+ public Base64InputStream(final InputStream in, final boolean doEncode, final int lineLength, final byte[] lineSeparator) {
super(in, new Base64(lineLength, lineSeparator), doEncode);
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java Mon Jan 7 16:08:05 2013
@@ -48,7 +48,7 @@ public class Base64OutputStream extends
* @param out
* OutputStream to wrap.
*/
- public Base64OutputStream(OutputStream out) {
+ public Base64OutputStream(final OutputStream out) {
this(out, true);
}
@@ -61,7 +61,7 @@ public class Base64OutputStream extends
* @param doEncode
* true if we should encode all data written to us, false if we should decode.
*/
- public Base64OutputStream(OutputStream out, boolean doEncode) {
+ public Base64OutputStream(final OutputStream out, final boolean doEncode) {
super(out,new Base64(false), doEncode);
}
@@ -81,7 +81,7 @@ public class Base64OutputStream extends
* If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n).
* If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored.
*/
- public Base64OutputStream(OutputStream out, boolean doEncode, int lineLength, byte[] lineSeparator) {
+ public Base64OutputStream(final OutputStream out, final boolean doEncode, final int lineLength, final byte[] lineSeparator) {
super(out, new Base64(lineLength, lineSeparator), doEncode);
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java Mon Jan 7 16:08:05 2013
@@ -179,7 +179,7 @@ public abstract class BaseNCodec impleme
* @param lineLength if > 0, use chunking with a length <code>lineLength</code>
* @param chunkSeparatorLength the chunk separator length, if relevant
*/
- protected BaseNCodec(int unencodedBlockSize, int encodedBlockSize, int lineLength, int chunkSeparatorLength) {
+ protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength) {
this.unencodedBlockSize = unencodedBlockSize;
this.encodedBlockSize = encodedBlockSize;
final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0;
@@ -193,7 +193,7 @@ public abstract class BaseNCodec impleme
* @param context the context to be used
* @return true if there is data still available for reading.
*/
- boolean hasData(Context context) { // package protected for access from I/O streams
+ boolean hasData(final Context context) { // package protected for access from I/O streams
return context.buffer != null;
}
@@ -203,7 +203,7 @@ public abstract class BaseNCodec impleme
* @param context the context to be used
* @return The amount of buffered data available for reading.
*/
- int available(Context context) { // package protected for access from I/O streams
+ int available(final Context context) { // package protected for access from I/O streams
return context.buffer != null ? context.pos - context.readPos : 0;
}
@@ -220,13 +220,13 @@ public abstract class BaseNCodec impleme
* Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}.
* @param context the context to be used
*/
- private byte[] resizeBuffer(Context context) {
+ private byte[] resizeBuffer(final Context context) {
if (context.buffer == null) {
context.buffer = new byte[getDefaultBufferSize()];
context.pos = 0;
context.readPos = 0;
} else {
- byte[] b = new byte[context.buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR];
+ final byte[] b = new byte[context.buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR];
System.arraycopy(context.buffer, 0, b, 0, context.buffer.length);
context.buffer = b;
}
@@ -239,7 +239,7 @@ public abstract class BaseNCodec impleme
* @param size minimum spare space required
* @param context the context to be used
*/
- protected byte[] ensureBufferSize(int size, Context context){
+ protected byte[] ensureBufferSize(final int size, final Context context){
if ((context.buffer == null) || (context.buffer.length < context.pos + size)){
return resizeBuffer(context);
}
@@ -262,9 +262,9 @@ public abstract class BaseNCodec impleme
* the context to be used
* @return The number of bytes successfully extracted into the provided byte[] array.
*/
- int readResults(byte[] b, int bPos, int bAvail, Context context) {
+ int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) {
if (context.buffer != null) {
- int len = Math.min(available(context), bAvail);
+ final int len = Math.min(available(context), bAvail);
System.arraycopy(context.buffer, context.readPos, b, bPos, len);
context.readPos += len;
if (context.readPos >= context.pos) {
@@ -282,7 +282,7 @@ public abstract class BaseNCodec impleme
* the byte to check
* @return true if byte is whitespace, false otherwise
*/
- protected static boolean isWhiteSpace(byte byteToCheck) {
+ protected static boolean isWhiteSpace(final byte byteToCheck) {
switch (byteToCheck) {
case ' ' :
case '\n' :
@@ -305,7 +305,7 @@ public abstract class BaseNCodec impleme
* if the parameter supplied is not of type byte[]
*/
@Override
- public Object encode(Object obj) throws EncoderException {
+ public Object encode(final Object obj) throws EncoderException {
if (!(obj instanceof byte[])) {
throw new EncoderException("Parameter supplied to Base-N encode is not a byte[]");
}
@@ -320,7 +320,7 @@ public abstract class BaseNCodec impleme
* a byte array containing binary data
* @return A String containing only Base-N character data
*/
- public String encodeToString(byte[] pArray) {
+ public String encodeToString(final byte[] pArray) {
return StringUtils.newStringUtf8(encode(pArray));
}
@@ -331,7 +331,7 @@ public abstract class BaseNCodec impleme
* @param pArray a byte array containing binary data
* @return String containing only character data in the appropriate alphabet.
*/
- public String encodeAsString(byte[] pArray){
+ public String encodeAsString(final byte[] pArray){
return StringUtils.newStringUtf8(encode(pArray));
}
@@ -347,7 +347,7 @@ public abstract class BaseNCodec impleme
* if the parameter supplied is not of type byte[]
*/
@Override
- public Object decode(Object obj) throws DecoderException {
+ public Object decode(final Object obj) throws DecoderException {
if (obj instanceof byte[]) {
return decode((byte[]) obj);
} else if (obj instanceof String) {
@@ -364,7 +364,7 @@ public abstract class BaseNCodec impleme
* A String containing Base-N character data
* @return a byte array containing binary data
*/
- public byte[] decode(String pArray) {
+ public byte[] decode(final String pArray) {
return decode(StringUtils.getBytesUtf8(pArray));
}
@@ -376,14 +376,14 @@ public abstract class BaseNCodec impleme
* @return a byte array containing binary data
*/
@Override
- public byte[] decode(byte[] pArray) {
+ public byte[] decode(final byte[] pArray) {
if (pArray == null || pArray.length == 0) {
return pArray;
}
- Context context = new Context();
+ final Context context = new Context();
decode(pArray, 0, pArray.length, context);
decode(pArray, 0, EOF, context); // Notify decoder of EOF.
- byte[] result = new byte[context.pos];
+ final byte[] result = new byte[context.pos];
readResults(result, 0, result.length, context);
return result;
}
@@ -396,14 +396,14 @@ public abstract class BaseNCodec impleme
* @return A byte array containing only the basen alphabetic character data
*/
@Override
- public byte[] encode(byte[] pArray) {
+ public byte[] encode(final byte[] pArray) {
if (pArray == null || pArray.length == 0) {
return pArray;
}
- Context context = new Context();
+ final Context context = new Context();
encode(pArray, 0, pArray.length, context);
encode(pArray, 0, EOF, context); // Notify encoder of EOF.
- byte[] buf = new byte[context.pos - context.readPos];
+ final byte[] buf = new byte[context.pos - context.readPos];
readResults(buf, 0, buf.length, context);
return buf;
}
@@ -434,7 +434,7 @@ public abstract class BaseNCodec impleme
* @return {@code true} if all bytes are valid characters in the alphabet or if the byte array is empty;
* {@code false}, otherwise
*/
- public boolean isInAlphabet(byte[] arrayOctet, boolean allowWSPad) {
+ public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) {
for (int i = 0; i < arrayOctet.length; i++) {
if (!isInAlphabet(arrayOctet[i]) &&
(!allowWSPad || (arrayOctet[i] != PAD) && !isWhiteSpace(arrayOctet[i]))) {
@@ -453,7 +453,7 @@ public abstract class BaseNCodec impleme
* the String is empty; {@code false}, otherwise
* @see #isInAlphabet(byte[], boolean)
*/
- public boolean isInAlphabet(String basen) {
+ public boolean isInAlphabet(final String basen) {
return isInAlphabet(StringUtils.getBytesUtf8(basen), true);
}
@@ -466,11 +466,11 @@ public abstract class BaseNCodec impleme
* byte array to test
* @return {@code true} if any byte is a valid character in the alphabet or PAD; {@code false} otherwise
*/
- protected boolean containsAlphabetOrPad(byte[] arrayOctet) {
+ protected boolean containsAlphabetOrPad(final byte[] arrayOctet) {
if (arrayOctet == null) {
return false;
}
- for (byte element : arrayOctet) {
+ for (final byte element : arrayOctet) {
if (PAD == element || isInAlphabet(element)) {
return true;
}
@@ -486,7 +486,7 @@ public abstract class BaseNCodec impleme
* @return amount of space needed to encoded the supplied array.
* Returns a long since a max-len array will require > Integer.MAX_VALUE
*/
- public long getEncodedLength(byte[] pArray) {
+ public long getEncodedLength(final byte[] pArray) {
// Calculate non-chunked size - rounded up to allow for padding
// cast to long is needed to avoid possibility of overflow
long len = ((pArray.length + unencodedBlockSize-1) / unencodedBlockSize) * (long) encodedBlockSize;
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java Mon Jan 7 16:08:05 2013
@@ -41,7 +41,7 @@ public class BaseNCodecInputStream exten
private final Context context = new Context();
- protected BaseNCodecInputStream(InputStream in, BaseNCodec baseNCodec, boolean doEncode) {
+ protected BaseNCodecInputStream(final InputStream in, final BaseNCodec baseNCodec, final boolean doEncode) {
super(in);
this.doEncode = doEncode;
this.baseNCodec = baseNCodec;
@@ -72,7 +72,7 @@ public class BaseNCodecInputStream exten
* @since 1.7
*/
@Override
- public synchronized void mark(int readLimit) {
+ public synchronized void mark(final int readLimit) {
}
/**
@@ -125,7 +125,7 @@ public class BaseNCodecInputStream exten
* if offset, len or buffer size are invalid
*/
@Override
- public int read(byte b[], int offset, int len) throws IOException {
+ public int read(final byte b[], final int offset, final int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (offset < 0 || len < 0) {
@@ -154,8 +154,8 @@ public class BaseNCodecInputStream exten
*/
while (readLen == 0) {
if (!baseNCodec.hasData(context)) {
- byte[] buf = new byte[doEncode ? 4096 : 8192];
- int c = in.read(buf);
+ final byte[] buf = new byte[doEncode ? 4096 : 8192];
+ final int c = in.read(buf);
if (doEncode) {
baseNCodec.encode(buf, 0, c, context);
} else {
@@ -188,7 +188,7 @@ public class BaseNCodecInputStream exten
* @since 1.7
*/
@Override
- public long skip(long n) throws IOException {
+ public long skip(final long n) throws IOException {
if (n < 0) {
throw new IllegalArgumentException("Negative skip length: " + n);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java Mon Jan 7 16:08:05 2013
@@ -42,7 +42,7 @@ public class BaseNCodecOutputStream exte
private final Context context = new Context();
// TODO should this be protected?
- public BaseNCodecOutputStream(OutputStream out, BaseNCodec basedCodec, boolean doEncode) {
+ public BaseNCodecOutputStream(final OutputStream out, final BaseNCodec basedCodec, final boolean doEncode) {
super(out);
this.baseNCodec = basedCodec;
this.doEncode = doEncode;
@@ -57,7 +57,7 @@ public class BaseNCodecOutputStream exte
* if an I/O error occurs.
*/
@Override
- public void write(int i) throws IOException {
+ public void write(final int i) throws IOException {
singleByte[0] = (byte) i;
write(singleByte, 0, 1);
}
@@ -81,7 +81,7 @@ public class BaseNCodecOutputStream exte
* if offset, len or buffer size are invalid
*/
@Override
- public void write(byte b[], int offset, int len) throws IOException {
+ public void write(final byte b[], final int offset, final int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (offset < 0 || len < 0) {
@@ -107,11 +107,11 @@ public class BaseNCodecOutputStream exte
* @throws IOException
* if an I/O error occurs.
*/
- private void flush(boolean propogate) throws IOException {
- int avail = baseNCodec.available(context);
+ private void flush(final boolean propogate) throws IOException {
+ final int avail = baseNCodec.available(context);
if (avail > 0) {
- byte[] buf = new byte[avail];
- int c = baseNCodec.readResults(buf, 0, avail, context);
+ final byte[] buf = new byte[avail];
+ final int c = baseNCodec.readResults(buf, 0, avail, context);
if (c > 0) {
out.write(buf, 0, c);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java Mon Jan 7 16:08:05 2013
@@ -79,7 +79,7 @@ public class BinaryCodec implements Bina
* @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
*/
@Override
- public byte[] encode(byte[] raw) {
+ public byte[] encode(final byte[] raw) {
return toAsciiBytes(raw);
}
@@ -94,7 +94,7 @@ public class BinaryCodec implements Bina
* @see org.apache.commons.codec.Encoder#encode(Object)
*/
@Override
- public Object encode(Object raw) throws EncoderException {
+ public Object encode(final Object raw) throws EncoderException {
if (!(raw instanceof byte[])) {
throw new EncoderException("argument not a byte array");
}
@@ -112,7 +112,7 @@ public class BinaryCodec implements Bina
* @see org.apache.commons.codec.Decoder#decode(Object)
*/
@Override
- public Object decode(Object ascii) throws DecoderException {
+ public Object decode(final Object ascii) throws DecoderException {
if (ascii == null) {
return EMPTY_BYTE_ARRAY;
}
@@ -137,7 +137,7 @@ public class BinaryCodec implements Bina
* @see org.apache.commons.codec.Decoder#decode(Object)
*/
@Override
- public byte[] decode(byte[] ascii) {
+ public byte[] decode(final byte[] ascii) {
return fromAscii(ascii);
}
@@ -149,7 +149,7 @@ public class BinaryCodec implements Bina
* @return the raw encoded binary where each bit corresponds to a byte in the byte array argument
* @see org.apache.commons.codec.Decoder#decode(Object)
*/
- public byte[] toByteArray(String ascii) {
+ public byte[] toByteArray(final String ascii) {
if (ascii == null) {
return EMPTY_BYTE_ARRAY;
}
@@ -168,12 +168,12 @@ public class BinaryCodec implements Bina
* each char represents an ASCII '0' or '1'
* @return the raw encoded binary where each bit corresponds to a char in the char array argument
*/
- public static byte[] fromAscii(char[] ascii) {
+ public static byte[] fromAscii(final char[] ascii) {
if (ascii == null || ascii.length == 0) {
return EMPTY_BYTE_ARRAY;
}
// get length/8 times bytes with 3 bit shifts to the right of the length
- byte[] l_raw = new byte[ascii.length >> 3];
+ final byte[] l_raw = new byte[ascii.length >> 3];
/*
* We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
* loop.
@@ -195,12 +195,12 @@ public class BinaryCodec implements Bina
* each byte represents an ASCII '0' or '1'
* @return the raw encoded binary where each bit corresponds to a byte in the byte array argument
*/
- public static byte[] fromAscii(byte[] ascii) {
+ public static byte[] fromAscii(final byte[] ascii) {
if (isEmpty(ascii)) {
return EMPTY_BYTE_ARRAY;
}
// get length/8 times bytes with 3 bit shifts to the right of the length
- byte[] l_raw = new byte[ascii.length >> 3];
+ final byte[] l_raw = new byte[ascii.length >> 3];
/*
* We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
* loop.
@@ -222,7 +222,7 @@ public class BinaryCodec implements Bina
* the source array
* @return {@code true} if the given array is {@code null} or empty (size 0.)
*/
- private static boolean isEmpty(byte[] array) {
+ private static boolean isEmpty(final byte[] array) {
return array == null || array.length == 0;
}
@@ -235,12 +235,12 @@ public class BinaryCodec implements Bina
* @return an array of 0 and 1 character bytes for each bit of the argument
* @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
*/
- public static byte[] toAsciiBytes(byte[] raw) {
+ public static byte[] toAsciiBytes(final byte[] raw) {
if (isEmpty(raw)) {
return EMPTY_BYTE_ARRAY;
}
// get 8 times the bytes with 3 bit shifts to the left of the length
- byte[] l_ascii = new byte[raw.length << 3];
+ final byte[] l_ascii = new byte[raw.length << 3];
/*
* We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
* loop.
@@ -265,12 +265,12 @@ public class BinaryCodec implements Bina
* @return an array of 0 and 1 characters for each bit of the argument
* @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
*/
- public static char[] toAsciiChars(byte[] raw) {
+ public static char[] toAsciiChars(final byte[] raw) {
if (isEmpty(raw)) {
return EMPTY_CHAR_ARRAY;
}
// get 8 times the bytes with 3 bit shifts to the left of the length
- char[] l_ascii = new char[raw.length << 3];
+ final char[] l_ascii = new char[raw.length << 3];
/*
* We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the
* loop.
@@ -295,7 +295,7 @@ public class BinaryCodec implements Bina
* @return a String of 0 and 1 characters representing the binary data
* @see org.apache.commons.codec.BinaryEncoder#encode(byte[])
*/
- public static String toAsciiString(byte[] raw) {
+ public static String toAsciiString(final byte[] raw) {
return new String(toAsciiChars(raw));
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Hex.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Hex.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Hex.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Hex.java Mon Jan 7 16:08:05 2013
@@ -74,15 +74,15 @@ public class Hex implements BinaryEncode
* @throws DecoderException
* Thrown if an odd number or illegal of characters is supplied
*/
- public static byte[] decodeHex(char[] data) throws DecoderException {
+ public static byte[] decodeHex(final char[] data) throws DecoderException {
- int len = data.length;
+ final int len = data.length;
if ((len & 0x01) != 0) {
throw new DecoderException("Odd number of characters.");
}
- byte[] out = new byte[len >> 1];
+ final byte[] out = new byte[len >> 1];
// two characters form the hex value.
for (int i = 0, j = 0; j < len; i++) {
@@ -105,7 +105,7 @@ public class Hex implements BinaryEncode
* a byte[] to convert to Hex characters
* @return A char[] containing hexadecimal characters
*/
- public static char[] encodeHex(byte[] data) {
+ public static char[] encodeHex(final byte[] data) {
return encodeHex(data, true);
}
@@ -121,7 +121,7 @@ public class Hex implements BinaryEncode
* @return A char[] containing hexadecimal characters
* @since 1.4
*/
- public static char[] encodeHex(byte[] data, boolean toLowerCase) {
+ public static char[] encodeHex(final byte[] data, final boolean toLowerCase) {
return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
}
@@ -137,9 +137,9 @@ public class Hex implements BinaryEncode
* @return A char[] containing hexadecimal characters
* @since 1.4
*/
- protected static char[] encodeHex(byte[] data, char[] toDigits) {
- int l = data.length;
- char[] out = new char[l << 1];
+ protected static char[] encodeHex(final byte[] data, final char[] toDigits) {
+ final int l = data.length;
+ final char[] out = new char[l << 1];
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
@@ -157,7 +157,7 @@ public class Hex implements BinaryEncode
* @return A String containing hexadecimal characters
* @since 1.4
*/
- public static String encodeHexString(byte[] data) {
+ public static String encodeHexString(final byte[] data) {
return new String(encodeHex(data));
}
@@ -172,8 +172,8 @@ public class Hex implements BinaryEncode
* @throws DecoderException
* Thrown if ch is an illegal hex character
*/
- protected static int toDigit(char ch, int index) throws DecoderException {
- int digit = Character.digit(ch, 16);
+ protected static int toDigit(final char ch, final int index) throws DecoderException {
+ final int digit = Character.digit(ch, 16);
if (digit == -1) {
throw new DecoderException("Illegal hexadecimal character " + ch + " at index " + index);
}
@@ -197,7 +197,7 @@ public class Hex implements BinaryEncode
* the charset.
* @since 1.7
*/
- public Hex(Charset charset) {
+ public Hex(final Charset charset) {
this.charset = charset;
}
@@ -211,7 +211,7 @@ public class Hex implements BinaryEncode
* @since 1.4
* @since 1.7 throws UnsupportedCharsetException if the named charset is unavailable
*/
- public Hex(String charsetName) {
+ public Hex(final String charsetName) {
this(Charset.forName(charsetName));
}
@@ -228,7 +228,7 @@ public class Hex implements BinaryEncode
* @see #decodeHex(char[])
*/
@Override
- public byte[] decode(byte[] array) throws DecoderException {
+ public byte[] decode(final byte[] array) throws DecoderException {
return decodeHex(new String(array, getCharset()).toCharArray());
}
@@ -246,11 +246,11 @@ public class Hex implements BinaryEncode
* @see #decodeHex(char[])
*/
@Override
- public Object decode(Object object) throws DecoderException {
+ public Object decode(final Object object) throws DecoderException {
try {
- char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object;
+ final char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object;
return decodeHex(charArray);
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
throw new DecoderException(e.getMessage(), e);
}
}
@@ -271,7 +271,7 @@ public class Hex implements BinaryEncode
* @see #encodeHex(byte[])
*/
@Override
- public byte[] encode(byte[] array) {
+ public byte[] encode(final byte[] array) {
return encodeHexString(array).getBytes(this.getCharset());
}
@@ -292,12 +292,12 @@ public class Hex implements BinaryEncode
* @see #encodeHex(byte[])
*/
@Override
- public Object encode(Object object) throws EncoderException {
+ public Object encode(final Object object) throws EncoderException {
try {
- byte[] byteArray = object instanceof String ?
+ final byte[] byteArray = object instanceof String ?
((String) object).getBytes(this.getCharset()) : (byte[]) object;
return encodeHex(byteArray);
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
throw new EncoderException(e.getMessage(), e);
}
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/StringUtils.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/StringUtils.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/StringUtils.java Mon Jan 7 16:08:05 2013
@@ -46,7 +46,7 @@ public class StringUtils {
* The {@link Charset} to encode the {@code String}
* @return the encoded bytes
*/
- private static byte[] getBytes(String string, Charset charset) {
+ private static byte[] getBytes(final String string, final Charset charset) {
if (string == null) {
return null;
}
@@ -67,7 +67,7 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesIso8859_1(String string) {
+ public static byte[] getBytesIso8859_1(final String string) {
return getBytes(string, Charsets.ISO_8859_1);
}
@@ -91,13 +91,13 @@ public class StringUtils {
* @see CharEncoding
* @see String#getBytes(String)
*/
- public static byte[] getBytesUnchecked(String string, String charsetName) {
+ public static byte[] getBytesUnchecked(final String string, final String charsetName) {
if (string == null) {
return null;
}
try {
return string.getBytes(charsetName);
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw StringUtils.newIllegalStateException(charsetName, e);
}
}
@@ -116,7 +116,7 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesUsAscii(String string) {
+ public static byte[] getBytesUsAscii(final String string) {
return getBytes(string, Charsets.US_ASCII);
}
@@ -134,7 +134,7 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesUtf16(String string) {
+ public static byte[] getBytesUtf16(final String string) {
return getBytes(string, Charsets.UTF_16);
}
@@ -152,7 +152,7 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesUtf16Be(String string) {
+ public static byte[] getBytesUtf16Be(final String string) {
return getBytes(string, Charsets.UTF_16BE);
}
@@ -170,7 +170,7 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesUtf16Le(String string) {
+ public static byte[] getBytesUtf16Le(final String string) {
return getBytes(string, Charsets.UTF_16LE);
}
@@ -188,11 +188,11 @@ public class StringUtils {
* @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
* @see #getBytesUnchecked(String, String)
*/
- public static byte[] getBytesUtf8(String string) {
+ public static byte[] getBytesUtf8(final String string) {
return getBytes(string, Charsets.UTF_8);
}
- private static IllegalStateException newIllegalStateException(String charsetName, UnsupportedEncodingException e) {
+ private static IllegalStateException newIllegalStateException(final String charsetName, final UnsupportedEncodingException e) {
return new IllegalStateException(charsetName + ": " + e);
}
@@ -209,7 +209,7 @@ public class StringUtils {
* Thrown if {@link Charsets#UTF_8} is not initialized, which should never happen since it is
* required by the Java platform specification.
*/
- private static String newString(byte[] bytes, Charset charset) {
+ private static String newString(final byte[] bytes, final Charset charset) {
return bytes == null ? null : new String(bytes, charset);
}
@@ -232,13 +232,13 @@ public class StringUtils {
* @see CharEncoding
* @see String#String(byte[], String)
*/
- public static String newString(byte[] bytes, String charsetName) {
+ public static String newString(final byte[] bytes, final String charsetName) {
if (bytes == null) {
return null;
}
try {
return new String(bytes, charsetName);
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw StringUtils.newIllegalStateException(charsetName, e);
}
}
@@ -255,7 +255,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringIso8859_1(byte[] bytes) {
+ public static String newStringIso8859_1(final byte[] bytes) {
return new String(bytes, Charsets.ISO_8859_1);
}
@@ -271,7 +271,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringUsAscii(byte[] bytes) {
+ public static String newStringUsAscii(final byte[] bytes) {
return new String(bytes, Charsets.US_ASCII);
}
@@ -287,7 +287,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringUtf16(byte[] bytes) {
+ public static String newStringUtf16(final byte[] bytes) {
return new String(bytes, Charsets.UTF_16);
}
@@ -303,7 +303,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringUtf16Be(byte[] bytes) {
+ public static String newStringUtf16Be(final byte[] bytes) {
return new String(bytes, Charsets.UTF_16BE);
}
@@ -319,7 +319,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringUtf16Le(byte[] bytes) {
+ public static String newStringUtf16Le(final byte[] bytes) {
return new String(bytes, Charsets.UTF_16LE);
}
@@ -335,7 +335,7 @@ public class StringUtils {
* required by the Java platform specification.
* @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
*/
- public static String newStringUtf8(byte[] bytes) {
+ public static String newStringUtf8(final byte[] bytes) {
return newString(bytes, Charsets.UTF_8);
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/B64.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/B64.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/B64.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/B64.java Mon Jan 7 16:08:05 2013
@@ -51,7 +51,7 @@ class B64 {
* @param buffer
* Where the output chars is appended to.
*/
- static void b64from24bit(byte b2, byte b1, byte b0, int outLen, StringBuilder buffer) {
+ static void b64from24bit(final byte b2, final byte b1, final byte b0, final int outLen, final StringBuilder buffer) {
// The bit masking is necessary because the JVM byte type is signed!
int w = ((b2 << 16) & 0x00ffffff) | ((b1 << 8) & 0x00ffff) | (b0 & 0xff);
// It's effectively a "for" loop but kept to resemble the original C code.
@@ -68,8 +68,8 @@ class B64 {
* @param num
* Number of chars to generate.
*/
- static String getRandomSalt(int num) {
- StringBuilder saltString = new StringBuilder();
+ static String getRandomSalt(final int num) {
+ final StringBuilder saltString = new StringBuilder();
for (int i = 1; i <= num; i++) {
saltString.append(B64T.charAt(new Random().nextInt(B64T.length())));
}
Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Crypt.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Crypt.java?rev=1429868&r1=1429867&r2=1429868&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Crypt.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/Crypt.java Mon Jan 7 16:08:05 2013
@@ -42,7 +42,7 @@ public class Crypt {
* @throws RuntimeException
* when a {@link java.security.NoSuchAlgorithmException} is caught.
*/
- public static String crypt(byte[] keyBytes) {
+ public static String crypt(final byte[] keyBytes) {
return crypt(keyBytes, null);
}
@@ -62,7 +62,7 @@ public class Crypt {
* @throws RuntimeException
* when a {@link java.security.NoSuchAlgorithmException} is caught.
*/
- public static String crypt(byte[] keyBytes, String salt) {
+ public static String crypt(final byte[] keyBytes, final String salt) {
if (salt == null) {
return Sha2Crypt.sha512Crypt(keyBytes);
} else if (salt.startsWith(Sha2Crypt.SHA512_PREFIX)) {
@@ -88,7 +88,7 @@ public class Crypt {
* @throws RuntimeException
* when a {@link java.security.NoSuchAlgorithmException} is caught.
*/
- public static String crypt(String key) {
+ public static String crypt(final String key) {
return crypt(key, null);
}
@@ -145,7 +145,7 @@ public class Crypt {
* @throws RuntimeException
* when a {@link java.security.NoSuchAlgorithmException} is caught. *
*/
- public static String crypt(String key, String salt) {
+ public static String crypt(final String key, final String salt) {
return crypt(key.getBytes(Charsets.UTF_8), salt);
}
}
|