Skip to content

Commit bc0ad1e

Browse files
committed
Use blocks. Refer to constants and methods where they are defined in BaseNCodec instead of the Base32 and Base64 subclasses (and other classes.)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/branches/generics@1161343 13f79535-47bb-0310-9956-ffa450edef68
1 parent f51e1e7 commit bc0ad1e

18 files changed

+326
-323
lines changed

src/java/org/apache/commons/codec/language/bm/Lang.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ public static Lang loadFromResource(String languageRulesResourceName, Languages
158158
// trim leading-trailing whitespace
159159
line = line.trim();
160160

161-
if (line.length() == 0)
161+
if (line.length() == 0) {
162162
continue; // empty lines can be safely skipped
163+
}
163164

164165
// split it up
165166
String[] parts = line.split("\\s+");

src/java/org/apache/commons/codec/language/bm/PhoneticEngine.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ public int length() {
189189
}
190190

191191
public CharSequence subSequence(int start, int end) {
192-
if (start == end)
192+
if (start == end) {
193193
return "";
194+
}
194195

195196
CharSequence res = cache[start][end - 1];
196197
if (res == null) {

src/java/org/apache/commons/codec/net/URLStringCodec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public URLStringCodec() {
5252
*
5353
* @return the default string charset.
5454
*/
55+
@Override
5556
public String getDefaultCharset() {
5657
return this.charset;
5758
}

src/test/org/apache/commons/codec/binary/Base32InputStreamTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void testCodec105() throws IOException {
128128
*/
129129
@Test
130130
public void testBase32EmptyInputStreamMimeChuckSize() throws Exception {
131-
testBase32EmptyInputStream(Base32.MIME_CHUNK_SIZE);
131+
testBase32EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE);
132132
}
133133

134134
/**
@@ -139,7 +139,7 @@ public void testBase32EmptyInputStreamMimeChuckSize() throws Exception {
139139
*/
140140
@Test
141141
public void testBase32EmptyInputStreamPemChuckSize() throws Exception {
142-
testBase32EmptyInputStream(Base32.PEM_CHUNK_SIZE);
142+
testBase32EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE);
143143
}
144144

145145
private void testBase32EmptyInputStream(int chuckSize) throws Exception {
@@ -160,12 +160,12 @@ public void testBase32InputStreamByChunk() throws Exception {
160160
// Hello World test.
161161
byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE);
162162
byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
163-
testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF);
163+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
164164

165165
// Single Byte test.
166166
encoded = StringUtils.getBytesUtf8("AA======\r\n");
167167
decoded = new byte[]{(byte) 0};
168-
testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF);
168+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
169169

170170
// // OpenSSL interop test.
171171
// encoded = StringUtils.getBytesUtf8(Base32TestData.ENCODED_32_CHARS_PER_LINE);
@@ -199,12 +199,12 @@ public void testBase32InputStreamByteByByte() throws Exception {
199199
// Hello World test.
200200
byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE);
201201
byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
202-
testByteByByte(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF);
202+
testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
203203

204204
// Single Byte test.
205205
encoded = StringUtils.getBytesUtf8("AA======\r\n");
206206
decoded = new byte[]{(byte) 0};
207-
testByteByByte(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF);
207+
testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
208208

209209
// // Single Line test.
210210
// String singleLine = Base32TestData.ENCODED_32_CHARS_PER_LINE.replaceAll("\n", "");

src/test/org/apache/commons/codec/binary/Base32OutputStreamTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class Base32OutputStreamTest {
6666
*/
6767
@Test
6868
public void testBase32EmptyOutputStreamMimeChunkSize() throws Exception {
69-
testBase32EmptyOutputStream(Base32.MIME_CHUNK_SIZE);
69+
testBase32EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE);
7070
}
7171

7272
/**
@@ -77,7 +77,7 @@ public void testBase32EmptyOutputStreamMimeChunkSize() throws Exception {
7777
*/
7878
@Test
7979
public void testBase32EmptyOutputStreamPemChunkSize() throws Exception {
80-
testBase32EmptyOutputStream(Base32.PEM_CHUNK_SIZE);
80+
testBase32EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE);
8181
}
8282

8383
private void testBase32EmptyOutputStream(int chunkSize) throws Exception {
@@ -98,7 +98,7 @@ public void testBase32OutputStreamByChunk() throws Exception {
9898
// Hello World test.
9999
byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE);
100100
byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE);
101-
testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF);
101+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
102102

103103
// // Single Byte test.
104104
// encoded = StringUtils.getBytesUtf8("AA==\r\n");

src/test/org/apache/commons/codec/binary/Base64InputStreamTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void testCodec98NPE() throws Exception {
138138
*/
139139
@Test
140140
public void testBase64EmptyInputStreamMimeChuckSize() throws Exception {
141-
testBase64EmptyInputStream(Base64.MIME_CHUNK_SIZE);
141+
testBase64EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE);
142142
}
143143

144144
/**
@@ -149,7 +149,7 @@ public void testBase64EmptyInputStreamMimeChuckSize() throws Exception {
149149
*/
150150
@Test
151151
public void testBase64EmptyInputStreamPemChuckSize() throws Exception {
152-
testBase64EmptyInputStream(Base64.PEM_CHUNK_SIZE);
152+
testBase64EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE);
153153
}
154154

155155
private void testBase64EmptyInputStream(int chuckSize) throws Exception {
@@ -170,17 +170,17 @@ public void testBase64InputStreamByChunk() throws Exception {
170170
// Hello World test.
171171
byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n");
172172
byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
173-
testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
173+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
174174

175175
// Single Byte test.
176176
encoded = StringUtils.getBytesUtf8("AA==\r\n");
177177
decoded = new byte[]{(byte) 0};
178-
testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
178+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
179179

180180
// OpenSSL interop test.
181181
encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE);
182182
decoded = Base64TestData.DECODED;
183-
testByChunk(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF);
183+
testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
184184

185185
// Single Line test.
186186
String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");
@@ -208,17 +208,17 @@ public void testBase64InputStreamByteByByte() throws Exception {
208208
// Hello World test.
209209
byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n");
210210
byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
211-
testByteByByte(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
211+
testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
212212

213213
// Single Byte test.
214214
encoded = StringUtils.getBytesUtf8("AA==\r\n");
215215
decoded = new byte[]{(byte) 0};
216-
testByteByByte(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
216+
testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
217217

218218
// OpenSSL interop test.
219219
encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE);
220220
decoded = Base64TestData.DECODED;
221-
testByteByByte(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF);
221+
testByteByByte(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
222222

223223
// Single Line test.
224224
String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");

src/test/org/apache/commons/codec/binary/Base64OutputStreamTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testCodec98NPE() throws Exception {
7272
*/
7373
@Test
7474
public void testBase64EmptyOutputStreamMimeChunkSize() throws Exception {
75-
testBase64EmptyOutputStream(Base64.MIME_CHUNK_SIZE);
75+
testBase64EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE);
7676
}
7777

7878
/**
@@ -83,7 +83,7 @@ public void testBase64EmptyOutputStreamMimeChunkSize() throws Exception {
8383
*/
8484
@Test
8585
public void testBase64EmptyOutputStreamPemChunkSize() throws Exception {
86-
testBase64EmptyOutputStream(Base64.PEM_CHUNK_SIZE);
86+
testBase64EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE);
8787
}
8888

8989
private void testBase64EmptyOutputStream(int chunkSize) throws Exception {
@@ -104,17 +104,17 @@ public void testBase64OutputStreamByChunk() throws Exception {
104104
// Hello World test.
105105
byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n");
106106
byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
107-
testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
107+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
108108

109109
// Single Byte test.
110110
encoded = StringUtils.getBytesUtf8("AA==\r\n");
111111
decoded = new byte[]{(byte) 0};
112-
testByChunk(encoded, decoded, Base64.MIME_CHUNK_SIZE, CRLF);
112+
testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF);
113113

114114
// OpenSSL interop test.
115115
encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE);
116116
decoded = Base64TestData.DECODED;
117-
testByChunk(encoded, decoded, Base64.PEM_CHUNK_SIZE, LF);
117+
testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF);
118118

119119
// Single Line test.
120120
String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", "");

src/test/org/apache/commons/codec/binary/Base64Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void testBase64() {
8282
encodedContent = StringUtils.newStringUtf8(encodedBytes);
8383
assertTrue("encoding hello world", encodedContent.equals("SGVsbG8gV29ybGQ="));
8484

85-
Base64 b64 = new Base64(Base64.MIME_CHUNK_SIZE, null); // null lineSeparator same as saying no-chunking
85+
Base64 b64 = new Base64(BaseNCodec.MIME_CHUNK_SIZE, null); // null lineSeparator same as saying no-chunking
8686
encodedBytes = b64.encode(StringUtils.getBytesUtf8(content));
8787
encodedContent = StringUtils.newStringUtf8(encodedBytes);
8888
assertTrue("encoding hello world", encodedContent.equals("SGVsbG8gV29ybGQ="));
@@ -519,15 +519,15 @@ public void testRfc2045Section2Dot1CrLfDefinition() {
519519
*/
520520
@Test
521521
public void testRfc2045Section6Dot8ChunkSizeDefinition() {
522-
assertEquals(76, Base64.MIME_CHUNK_SIZE);
522+
assertEquals(76, BaseNCodec.MIME_CHUNK_SIZE);
523523
}
524524

525525
/**
526526
* Tests RFC 1421 section 4.3.2.4 chuck size definition.
527527
*/
528528
@Test
529529
public void testRfc1421Section6Dot8ChunkSizeDefinition() {
530-
assertEquals(64, Base64.PEM_CHUNK_SIZE);
530+
assertEquals(64, BaseNCodec.PEM_CHUNK_SIZE);
531531
}
532532

533533
/**

0 commit comments

Comments
 (0)