Author: ggregory Date: Thu Aug 25 00:34:24 2011 New Revision: 1161342 URL: http://svn.apache.org/viewvc?rev=1161342&view=rev Log: Use blocks. Refer to constants where they are defined in BaseNCodec instead of the Base32 and Base64 subclasses.
Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/Lang.java Thu Aug 25 00:34:24 2011 @@ -158,8 +158,9 @@ public class Lang { // trim leading-trailing whitespace line = line.trim(); - if (line.length() == 0) + if (line.length() == 0) { continue; // empty lines can be safely skipped + } // split it up String[] parts = line.split("\\s+"); Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java Thu Aug 25 00:34:24 2011 @@ -189,8 +189,9 @@ public class PhoneticEngine { } public CharSequence subSequence(int start, int end) { - if (start == end) + if (start == end) { return ""; + } CharSequence res = cache[start][end - 1]; if (res == null) { Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java Thu Aug 25 00:34:24 2011 @@ -128,7 +128,7 @@ public class Base32InputStreamTest { */ @Test public void testBase32EmptyInputStreamMimeChuckSize() throws Exception { - testBase32EmptyInputStream(Base32.MIME_CHUNK_SIZE); + testBase32EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** @@ -139,7 +139,7 @@ public class Base32InputStreamTest { */ @Test public void testBase32EmptyInputStreamPemChuckSize() throws Exception { - testBase32EmptyInputStream(Base32.PEM_CHUNK_SIZE); + testBase32EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase32EmptyInputStream(int chuckSize) throws Exception { @@ -160,12 +160,12 @@ public class Base32InputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); - testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA======\r\n"); decoded = new byte[]{(byte) 0}; - testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // OpenSSL interop test. // encoded = StringUtils.getBytesUtf8(Base32TestData.ENCODED_32_CHARS_PER_LINE); @@ -199,12 +199,12 @@ public class Base32InputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); - testByteByByte(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); + testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA======\r\n"); decoded = new byte[]{(byte) 0}; - testByteByByte(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); + testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // Single Line test. // String singleLine = Base32TestData.ENCODED_32_CHARS_PER_LINE.replaceAll("\n", ""); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java Thu Aug 25 00:34:24 2011 @@ -66,7 +66,7 @@ public class Base32OutputStreamTest { */ @Test public void testBase32EmptyOutputStreamMimeChunkSize() throws Exception { - testBase32EmptyOutputStream(Base32.MIME_CHUNK_SIZE); + testBase32EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** @@ -77,7 +77,7 @@ public class Base32OutputStreamTest { */ @Test public void testBase32EmptyOutputStreamPemChunkSize() throws Exception { - testBase32EmptyOutputStream(Base32.PEM_CHUNK_SIZE); + testBase32EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase32EmptyOutputStream(int chunkSize) throws Exception { @@ -98,7 +98,7 @@ public class Base32OutputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); - testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // Single Byte test. // encoded = StringUtils.getBytesUtf8("AA==\r\n"); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java Thu Aug 25 00:34:24 2011 @@ -138,7 +138,7 @@ public class Base64InputStreamTest { */ @Test public void testBase64EmptyInputStreamMimeChuckSize() throws Exception { - testBase64EmptyInputStream(Base64.MIME_CHUNK_SIZE); + testBase64EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** @@ -149,7 +149,7 @@ public class Base64InputStreamTest { */ @Test public void testBase64EmptyInputStreamPemChuckSize() throws Exception { - testBase64EmptyInputStream(Base64.PEM_CHUNK_SIZE); + testBase64EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase64EmptyInputStream(int chuckSize) throws Exception { @@ -170,17 +170,17 @@ public class Base64InputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); - testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[]{(byte) 0}; - testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; - testByChunk(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF); + testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); @@ -208,17 +208,17 @@ public class Base64InputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); - testByteByByte(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[]{(byte) 0}; - testByteByByte(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; - testByteByByte(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF); + testByteByByte(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java Thu Aug 25 00:34:24 2011 @@ -72,7 +72,7 @@ public class Base64OutputStreamTest { */ @Test public void testBase64EmptyOutputStreamMimeChunkSize() throws Exception { - testBase64EmptyOutputStream(Base64.MIME_CHUNK_SIZE); + testBase64EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** @@ -83,7 +83,7 @@ public class Base64OutputStreamTest { */ @Test public void testBase64EmptyOutputStreamPemChunkSize() throws Exception { - testBase64EmptyOutputStream(Base64.PEM_CHUNK_SIZE); + testBase64EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase64EmptyOutputStream(int chunkSize) throws Exception { @@ -104,17 +104,17 @@ public class Base64OutputStreamTest { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); - testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[]{(byte) 0}; - testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF); + testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; - testByChunk(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF); + testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java?rev=1161342&r1=1161341&r2=1161342&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/binary/Base64Test.java Thu Aug 25 00:34:24 2011 @@ -83,7 +83,7 @@ public class Base64Test { encodedContent = StringUtils.newStringUtf8(encodedBytes); assertTrue("encoding hello world", encodedContent.equals("SGVsbG8gV29ybGQ=")); - Base64 b64 = new Base64(Base64.MIME_CHUNK_SIZE, null); // null lineSeparator same as saying no-chunking + Base64 b64 = new Base64(BaseNCodec.MIME_CHUNK_SIZE, null); // null lineSeparator same as saying no-chunking encodedBytes = b64.encode(StringUtils.getBytesUtf8(content)); encodedContent = StringUtils.newStringUtf8(encodedBytes); assertTrue("encoding hello world", encodedContent.equals("SGVsbG8gV29ybGQ=")); @@ -544,7 +544,7 @@ public class Base64Test { */ @Test public void testRfc2045Section6Dot8ChunkSizeDefinition() { - assertEquals(76, Base64.MIME_CHUNK_SIZE); + assertEquals(76, BaseNCodec.MIME_CHUNK_SIZE); } /** @@ -552,7 +552,7 @@ public class Base64Test { */ @Test public void testRfc1421Section6Dot8ChunkSizeDefinition() { - assertEquals(64, Base64.PEM_CHUNK_SIZE); + assertEquals(64, BaseNCodec.PEM_CHUNK_SIZE); } /**