Author: ggregory Date: Thu Aug 30 13:31:12 2012 New Revision: 1378928 URL: http://svn.apache.org/viewvc?rev=1378928&view=rev Log: Fix checkstyle issues (line lengths).
Modified: 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/BaseNCodec.java 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=1378928&r1=1378927&r2=1378928&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 Thu Aug 30 13:31:12 2012 @@ -36,8 +36,9 @@ import java.math.BigInteger; * </ul> * </p> * <p> - * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode - * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). + * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only + * encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, + * UTF-8, etc). * </p> * <p> * This class is thread-safe. @@ -98,8 +99,8 @@ public class Base64 extends BaseNCodec { }; /** - * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in - * Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 + * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified + * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 * alphabet but fall within the bounds of the array are translated to -1. * * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both @@ -172,7 +173,8 @@ public class Base64 extends BaseNCodec { /** * Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode. * <p> - * When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. + * When encoding the line length is 76, the line separator is CRLF, and the encoding table is + * STANDARD_ENCODE_TABLE. * </p> * * <p> @@ -180,8 +182,7 @@ public class Base64 extends BaseNCodec { * </p> * * @param urlSafe - * if {@code true}, URL-safe encoding is used. In most cases this should be set to - * {@code false}. + * 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) { @@ -202,8 +203,9 @@ public class Base64 extends BaseNCodec { * </p> * * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). - * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding. + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. * @since 1.4 */ public Base64(int lineLength) { @@ -224,8 +226,9 @@ public class Base64 extends BaseNCodec { * </p> * * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). - * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding. + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @throws IllegalArgumentException @@ -250,8 +253,9 @@ public class Base64 extends BaseNCodec { * </p> * * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). - * If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding. + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @param urlSafe @@ -315,7 +319,8 @@ public class Base64 extends BaseNCodec { * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. - * @param context the context to be used + * @param context + * the context to be used */ @Override void encode(byte[] in, int inPos, int inAvail, Context context) { @@ -333,8 +338,10 @@ public class Base64 extends BaseNCodec { int savedPos = context.pos; switch (context.modulus) { // 0-2 case 1 : // 8 bits = 6 + 2 - context.buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; // top 6 bits - context.buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; // remaining 2 + // top 6 bits: + context.buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; + // remaining 2: + context.buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; // URL-SAFE skips the padding to further reduce size. if (encodeTable == STANDARD_ENCODE_TABLE) { context.buffer[context.pos++] = PAD; @@ -405,7 +412,8 @@ public class Base64 extends BaseNCodec { * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. - * @param context the context to be used + * @param context + * the context to be used */ @Override void decode(byte[] in, int inPos, int inAvail, Context context) { 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=1378928&r1=1378927&r2=1378928&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 Thu Aug 30 13:31:12 2012 @@ -76,14 +76,14 @@ public abstract class BaseNCodec impleme boolean eof; /** - * Variable tracks how many characters have been written to the current line. Only used when encoding. We use it to - * make sure each encoded line never goes beyond lineLength (if lineLength > 0). + * Variable tracks how many characters have been written to the current line. Only used when encoding. We use + * it to make sure each encoded line never goes beyond lineLength (if lineLength > 0). */ int currentLinePos; /** - * Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. - * This variable helps track that. + * Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This + * variable helps track that. */ int modulus; @@ -166,10 +166,11 @@ 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(int unencodedBlockSize, int encodedBlockSize, int lineLength, int chunkSeparatorLength) { this.unencodedBlockSize = unencodedBlockSize; this.encodedBlockSize = encodedBlockSize; - this.lineLength = (lineLength > 0 && chunkSeparatorLength > 0) ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; + final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0; + this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; this.chunkSeparatorLength = chunkSeparatorLength; } @@ -231,8 +232,10 @@ public abstract class BaseNCodec impleme } /** - * Extracts buffered data into the provided byte[] array, starting at position bPos, - * up to a maximum of bAvail bytes. Returns how many bytes were actually extracted. + * Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail + * bytes. Returns how many bytes were actually extracted. + * <p> + * Package protected for access from I/O streams. * * @param b * byte[] array to extract the buffered data into. @@ -240,10 +243,11 @@ public abstract class BaseNCodec impleme * position in byte[] array to start extraction at. * @param bAvail * amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). - * @param context the context to be used + * @param context + * 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) { // package protected for access from I/O streams + int readResults(byte[] b, int bPos, int bAvail, Context context) { if (context.buffer != null) { int len = Math.min(available(context), bAvail); System.arraycopy(context.buffer, context.readPos, b, bPos, len); @@ -276,8 +280,8 @@ public abstract class BaseNCodec impleme } /** - * Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of the - * Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[]. + * Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of + * the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[]. * * @param obj * Object to encode @@ -317,12 +321,13 @@ public abstract class BaseNCodec impleme } /** - * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of the - * Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. + * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of + * the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. * * @param obj * Object to decode - * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String supplied. + * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String + * supplied. * @throws DecoderException * if the parameter supplied is not of type byte[] */ @@ -388,9 +393,11 @@ public abstract class BaseNCodec impleme return buf; } - abstract void encode(byte[] pArray, int i, int length, Context context); // package protected for access from I/O streams + // package protected for access from I/O streams + abstract void encode(byte[] pArray, int i, int length, Context context); - abstract void decode(byte[] pArray, int i, int length, Context context); // package protected for access from I/O streams + // package protected for access from I/O streams + abstract void decode(byte[] pArray, int i, int length, Context context); /** * Returns whether or not the <code>octet</code> is in the current alphabet.