Skip to content

Commit 76d42c0

Browse files
author
Gary Gregory
committed
Better private ivar name.
1 parent 6f82a45 commit 76d42c0

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private String readLine() throws IOException {
152152
final byte[] lineData = new byte[lineLengthBytes];
153153
System.arraycopy(data, lineStart, lineData, 0, lineLengthBytes);
154154

155-
line = new String(lineData, encoding);
155+
line = new String(lineData, charset);
156156

157157
currentLastBytePos = i - newLineMatchByteCount;
158158
break; // found line
@@ -171,7 +171,7 @@ private String readLine() throws IOException {
171171
// --- last file part handling ---
172172
if (isLastFilePart && leftOver != null) {
173173
// there will be no line break anymore, this is the first line of the file
174-
line = new String(leftOver, encoding);
174+
line = new String(leftOver, charset);
175175
leftOver = null;
176176
}
177177

@@ -197,7 +197,7 @@ private FilePart rollOver() throws IOException {
197197
// NO 1 was the last FilePart, we're finished
198198
if (leftOver != null) {
199199
throw new IllegalStateException("Unexpected leftover of the last block: leftOverOfThisFilePart="
200-
+ new String(leftOver, encoding));
200+
+ new String(leftOver, charset));
201201
}
202202
return null;
203203
}
@@ -207,7 +207,7 @@ private FilePart rollOver() throws IOException {
207207
private static final int DEFAULT_BLOCK_SIZE = IOUtils.DEFAULT_BUFFER_SIZE;
208208

209209
private final int blockSize;
210-
private final Charset encoding;
210+
private final Charset charset;
211211
private final SeekableByteChannel channel;
212212
private final long totalByteLength;
213213
private final long totalBlockCount;
@@ -303,32 +303,32 @@ public ReversedLinesFileReader(final Path file, final Charset charset) throws IO
303303
*/
304304
public ReversedLinesFileReader(final Path file, final int blockSize, final Charset charset) throws IOException {
305305
this.blockSize = blockSize;
306-
this.encoding = Charsets.toCharset(charset);
306+
this.charset = Charsets.toCharset(charset);
307307

308308
// --- check & prepare encoding ---
309-
final CharsetEncoder charsetEncoder = this.encoding.newEncoder();
309+
final CharsetEncoder charsetEncoder = this.charset.newEncoder();
310310
final float maxBytesPerChar = charsetEncoder.maxBytesPerChar();
311311
if (maxBytesPerChar == 1f) {
312312
// all one byte encodings are no problem
313313
byteDecrement = 1;
314-
} else if (this.encoding == StandardCharsets.UTF_8) {
314+
} else if (this.charset == StandardCharsets.UTF_8) {
315315
// UTF-8 works fine out of the box, for multibyte sequences a second UTF-8 byte
316316
// can never be a newline byte
317317
// http://en.wikipedia.org/wiki/UTF-8
318318
byteDecrement = 1;
319-
} else if (this.encoding == Charset.forName("Shift_JIS") || // Same as for UTF-8
319+
} else if (this.charset == Charset.forName("Shift_JIS") || // Same as for UTF-8
320320
// http://www.herongyang.com/Unicode/JIS-Shift-JIS-Encoding.html
321-
this.encoding == Charset.forName("windows-31j") || // Windows code page 932 (Japanese)
322-
this.encoding == Charset.forName("x-windows-949") || // Windows code page 949 (Korean)
323-
this.encoding == Charset.forName("gbk") || // Windows code page 936 (Simplified Chinese)
324-
this.encoding == Charset.forName("x-windows-950")) { // Windows code page 950 (Traditional Chinese)
321+
this.charset == Charset.forName("windows-31j") || // Windows code page 932 (Japanese)
322+
this.charset == Charset.forName("x-windows-949") || // Windows code page 949 (Korean)
323+
this.charset == Charset.forName("gbk") || // Windows code page 936 (Simplified Chinese)
324+
this.charset == Charset.forName("x-windows-950")) { // Windows code page 950 (Traditional Chinese)
325325
byteDecrement = 1;
326-
} else if (this.encoding == StandardCharsets.UTF_16BE || this.encoding == StandardCharsets.UTF_16LE) {
326+
} else if (this.charset == StandardCharsets.UTF_16BE || this.charset == StandardCharsets.UTF_16LE) {
327327
// UTF-16 new line sequences are not allowed as second tuple of four byte
328328
// sequences,
329329
// however byte order has to be specified
330330
byteDecrement = 2;
331-
} else if (this.encoding == StandardCharsets.UTF_16) {
331+
} else if (this.charset == StandardCharsets.UTF_16) {
332332
throw new UnsupportedEncodingException(
333333
"For UTF-16, you need to specify the byte order (use UTF-16BE or " + "UTF-16LE)");
334334
} else {
@@ -338,8 +338,8 @@ public ReversedLinesFileReader(final Path file, final int blockSize, final Chars
338338

339339
// NOTE: The new line sequences are matched in the order given, so it is
340340
// important that \r\n is BEFORE \n
341-
this.newLineSequences = new byte[][] { "\r\n".getBytes(this.encoding), "\n".getBytes(this.encoding),
342-
"\r".getBytes(this.encoding) };
341+
this.newLineSequences = new byte[][] { "\r\n".getBytes(this.charset), "\n".getBytes(this.charset),
342+
"\r".getBytes(this.charset) };
343343

344344
this.avoidNewlineSplitBufferSize = newLineSequences[0].length;
345345

0 commit comments

Comments
 (0)