Skip to content

Commit 9f6d3f5

Browse files
committed
Rename readAgain() to getLastChar()
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1397911 13f79535-47bb-0310-9956-ffa450edef68
1 parent f342cb2 commit 9f6d3f5

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/main/java/org/apache/commons/csv/CSVLexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public CSVLexer(final CSVFormat format, final ExtendedBufferedReader in) {
4747
Token nextToken(final Token token) throws IOException {
4848

4949
// get the last read char (required for empty line detection)
50-
int lastChar = in.readAgain();
50+
int lastChar = in.getLastChar();
5151

5252
// read the next char and set eol
5353
int c = in.read();

src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public int read() throws IOException {
6565
*
6666
* @return the last character that was read
6767
*/
68-
int readAgain() {
68+
int getLastChar() {
6969
return lastChar;
7070
}
7171

src/test/java/org/apache/commons/csv/CSVLexer1.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Token nextToken(Token tkn) throws IOException {
4747
wsBuf.setLength(0); // reuse
4848

4949
// get the last read char (required for empty line detection)
50-
int lastChar = in.readAgain();
50+
int lastChar = in.getLastChar();
5151

5252
// read the next char and set eol
5353
/* note: unfortunately isEndOfLine may consumes a character silently.
@@ -56,7 +56,7 @@ Token nextToken(Token tkn) throws IOException {
5656
*/
5757
int c = in.read();
5858
boolean eol = isEndOfLine(c);
59-
c = in.readAgain();
59+
c = in.getLastChar();
6060

6161
// empty line detection: eol AND (last char was EOL or beginning)
6262
if (format.getIgnoreEmptyLines()) {
@@ -67,7 +67,7 @@ Token nextToken(Token tkn) throws IOException {
6767
lastChar = c;
6868
c = in.read();
6969
eol = isEndOfLine(c);
70-
c = in.readAgain();
70+
c = in.getLastChar();
7171
// reached end of file without any content (empty line at the end)
7272
if (isEndOfFile(c)) {
7373
tkn.type = EOF;

src/test/java/org/apache/commons/csv/CSVLexer1306663.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public CSVLexer1306663(final CSVFormat format, final ExtendedBufferedReader in)
4545
Token nextToken(final Token tkn) throws IOException {
4646

4747
// get the last read char (required for empty line detection)
48-
int lastChar = in.readAgain();
48+
int lastChar = in.getLastChar();
4949

5050
// read the next char and set eol
5151
int c = in.read();
@@ -61,7 +61,7 @@ Token nextToken(final Token tkn) throws IOException {
6161
* is to call 'readAgain' on the stream...
6262
*/
6363
boolean eol = isEndOfLine(c);
64-
c = in.readAgain();
64+
c = in.getLastChar();
6565

6666
// empty line detection: eol AND (last char was EOL or beginning)
6767
if (ignoreEmptyLines) {
@@ -70,7 +70,7 @@ Token nextToken(final Token tkn) throws IOException {
7070
lastChar = c;
7171
c = in.read();
7272
eol = isEndOfLine(c);
73-
c = in.readAgain();
73+
c = in.getLastChar();
7474
// reached end of file without any content (empty line at the end)
7575
if (isEndOfFile(c)) {
7676
tkn.type = EOF;

src/test/java/org/apache/commons/csv/CSVLexer1306667.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public CSVLexer1306667(final CSVFormat format, final ExtendedBufferedReader in)
4545
Token nextToken(final Token tkn) throws IOException {
4646

4747
// get the last read char (required for empty line detection)
48-
int lastChar = in.readAgain();
48+
int lastChar = in.getLastChar();
4949

5050
// read the next char and set eol
5151
int c = in.read();
@@ -55,7 +55,7 @@ Token nextToken(final Token tkn) throws IOException {
5555
* is to call 'readAgain' on the stream...
5656
*/
5757
boolean eol = isEndOfLine(c);
58-
c = in.readAgain();
58+
c = in.getLastChar();
5959

6060
// empty line detection: eol AND (last char was EOL or beginning)
6161
if (ignoreEmptyLines) {
@@ -64,7 +64,7 @@ Token nextToken(final Token tkn) throws IOException {
6464
lastChar = c;
6565
c = in.read();
6666
eol = isEndOfLine(c);
67-
c = in.readAgain();
67+
c = in.getLastChar();
6868
// reached end of file without any content (empty line at the end)
6969
if (isEndOfFile(c)) {
7070
tkn.type = EOF;

src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void testEmptyInput() throws Exception {
3434
final ExtendedBufferedReader br = getBufferedReader("");
3535
assertEquals(END_OF_STREAM, br.read());
3636
assertEquals(END_OF_STREAM, br.lookAhead());
37-
assertEquals(END_OF_STREAM, br.readAgain());
37+
assertEquals(END_OF_STREAM, br.getLastChar());
3838
assertNull(br.readLine());
3939
assertEquals(0, br.read(new char[10], 0, 0));
4040
}
@@ -43,48 +43,48 @@ public void testEmptyInput() throws Exception {
4343
public void testReadLookahead1() throws Exception {
4444
final ExtendedBufferedReader br = getBufferedReader("1\n2\r3\n");
4545
assertEquals('1', br.lookAhead());
46-
assertEquals(UNDEFINED, br.readAgain());
46+
assertEquals(UNDEFINED, br.getLastChar());
4747
assertEquals('1', br.read());
48-
assertEquals('1', br.readAgain());
48+
assertEquals('1', br.getLastChar());
4949

5050
assertEquals(0, br.getLineNumber());
5151
assertEquals('\n', br.lookAhead());
5252
assertEquals(0, br.getLineNumber());
53-
assertEquals('1', br.readAgain());
53+
assertEquals('1', br.getLastChar());
5454
assertEquals('\n', br.read());
5555
assertEquals(1, br.getLineNumber());
56-
assertEquals('\n', br.readAgain());
56+
assertEquals('\n', br.getLastChar());
5757
assertEquals(1, br.getLineNumber());
5858

5959
assertEquals('2', br.lookAhead());
6060
assertEquals(1, br.getLineNumber());
61-
assertEquals('\n', br.readAgain());
61+
assertEquals('\n', br.getLastChar());
6262
assertEquals(1, br.getLineNumber());
6363
assertEquals('2', br.read());
64-
assertEquals('2', br.readAgain());
64+
assertEquals('2', br.getLastChar());
6565

6666
assertEquals('\r', br.lookAhead());
67-
assertEquals('2', br.readAgain());
67+
assertEquals('2', br.getLastChar());
6868
assertEquals('\r', br.read());
69-
assertEquals('\r', br.readAgain());
69+
assertEquals('\r', br.getLastChar());
7070

7171
assertEquals('3', br.lookAhead());
72-
assertEquals('\r', br.readAgain());
72+
assertEquals('\r', br.getLastChar());
7373
assertEquals('3', br.read());
74-
assertEquals('3', br.readAgain());
74+
assertEquals('3', br.getLastChar());
7575

7676
assertEquals('\n', br.lookAhead());
7777
assertEquals(2, br.getLineNumber());
78-
assertEquals('3', br.readAgain());
78+
assertEquals('3', br.getLastChar());
7979
assertEquals('\n', br.read());
8080
assertEquals(3, br.getLineNumber());
81-
assertEquals('\n', br.readAgain());
81+
assertEquals('\n', br.getLastChar());
8282
assertEquals(3, br.getLineNumber());
8383

8484
assertEquals(END_OF_STREAM, br.lookAhead());
85-
assertEquals('\n', br.readAgain());
85+
assertEquals('\n', br.getLastChar());
8686
assertEquals(END_OF_STREAM, br.read());
87-
assertEquals(END_OF_STREAM, br.readAgain());
87+
assertEquals(END_OF_STREAM, br.getLastChar());
8888
assertEquals(END_OF_STREAM, br.read());
8989
assertEquals(END_OF_STREAM, br.lookAhead());
9090

@@ -101,13 +101,13 @@ public void testReadLookahead2() throws Exception {
101101
ref[2] = 'c';
102102
assertEquals(3, br.read(res, 0, 3));
103103
assertArrayEquals(ref, res);
104-
assertEquals('c', br.readAgain());
104+
assertEquals('c', br.getLastChar());
105105

106106
assertEquals('d', br.lookAhead());
107107
ref[4] = 'd';
108108
assertEquals(1, br.read(res, 4, 1));
109109
assertArrayEquals(ref, res);
110-
assertEquals('d', br.readAgain());
110+
assertEquals('d', br.getLastChar());
111111
}
112112

113113
@Test

0 commit comments

Comments
 (0)