@@ -55,11 +55,11 @@ final class Lexer {
5555 private final boolean ignoreEmptyLines ;
5656
5757 /** The input stream */
58- private final ExtendedBufferedReader in ;
58+ private final ExtendedBufferedReader reader ;
5959
6060 /** INTERNAL API. but ctor needs to be called dynamically by PerformanceTest class */
61- Lexer (final CSVFormat format , final ExtendedBufferedReader in ) {
62- this .in = in ;
61+ Lexer (final CSVFormat format , final ExtendedBufferedReader reader ) {
62+ this .reader = reader ;
6363 this .delimiter = format .getDelimiter ();
6464 this .escape = mapNullToDisabled (format .getEscape ());
6565 this .quoteChar = mapNullToDisabled (format .getQuoteChar ());
@@ -82,10 +82,10 @@ final class Lexer {
8282 Token nextToken (final Token token ) throws IOException {
8383
8484 // get the last read char (required for empty line detection)
85- int lastChar = in .getLastChar ();
85+ int lastChar = reader .getLastChar ();
8686
8787 // read the next char and set eol
88- int c = in .read ();
88+ int c = reader .read ();
8989 /*
9090 * Note: The following call will swallow LF if c == CR. But we don't need to know if the last char was CR or LF
9191 * - they are equivalent here.
@@ -97,7 +97,7 @@ Token nextToken(final Token token) throws IOException {
9797 while (eol && isStartOfLine (lastChar )) {
9898 // go on char ahead ...
9999 lastChar = c ;
100- c = in .read ();
100+ c = reader .read ();
101101 eol = readEndOfLine (c );
102102 // reached end of file without any content (empty line at the end)
103103 if (isEndOfFile (c )) {
@@ -116,7 +116,7 @@ Token nextToken(final Token token) throws IOException {
116116 }
117117
118118 if (isStartOfLine (lastChar ) && isCommentStart (c )) {
119- final String line = in .readLine ();
119+ final String line = reader .readLine ();
120120 if (line == null ) {
121121 token .type = EOF ;
122122 // don't set token.isReady here because no content
@@ -133,7 +133,7 @@ Token nextToken(final Token token) throws IOException {
133133 // ignore whitespaces at beginning of a token
134134 if (ignoreSurroundingSpaces ) {
135135 while (isWhitespace (c ) && !eol ) {
136- c = in .read ();
136+ c = reader .read ();
137137 eol = readEndOfLine (c );
138138 }
139139 }
@@ -198,14 +198,14 @@ private Token parseSimpleToken(final Token token, int ch) throws IOException {
198198 } else if (isEscape (ch )) {
199199 final int unescaped = readEscape ();
200200 if (unescaped == Constants .END_OF_STREAM ) { // unexpected char after escape
201- token .content .append ((char ) ch ).append ((char ) in .getLastChar ());
201+ token .content .append ((char ) ch ).append ((char ) reader .getLastChar ());
202202 } else {
203203 token .content .append ((char ) unescaped );
204204 }
205- ch = in .read (); // continue
205+ ch = reader .read (); // continue
206206 } else {
207207 token .content .append ((char ) ch );
208- ch = in .read (); // continue
208+ ch = reader .read (); // continue
209209 }
210210 }
211211
@@ -241,24 +241,24 @@ private Token parseEncapsulatedToken(final Token token) throws IOException {
241241 final long startLineNumber = getCurrentLineNumber ();
242242 int c ;
243243 while (true ) {
244- c = in .read ();
244+ c = reader .read ();
245245
246246 if (isEscape (c )) {
247247 final int unescaped = readEscape ();
248248 if (unescaped == Constants .END_OF_STREAM ) { // unexpected char after escape
249- token .content .append ((char ) c ).append ((char ) in .getLastChar ());
249+ token .content .append ((char ) c ).append ((char ) reader .getLastChar ());
250250 } else {
251251 token .content .append ((char ) unescaped );
252252 }
253253 } else if (isQuoteChar (c )) {
254- if (isQuoteChar (in .lookAhead ())) {
254+ if (isQuoteChar (reader .lookAhead ())) {
255255 // double or escaped encapsulator -> add single encapsulator to token
256- c = in .read ();
256+ c = reader .read ();
257257 token .content .append ((char ) c );
258258 } else {
259259 // token finish mark (encapsulator) reached: ignore whitespace till delimiter
260260 while (true ) {
261- c = in .read ();
261+ c = reader .read ();
262262 if (isDelimiter (c )) {
263263 token .type = TOKEN ;
264264 return token ;
@@ -297,7 +297,7 @@ private char mapNullToDisabled(final Character c) {
297297 * @return the current line number
298298 */
299299 long getCurrentLineNumber () {
300- return in .getCurrentLineNumber ();
300+ return reader .getCurrentLineNumber ();
301301 }
302302
303303 // TODO escape handling needs more work
@@ -314,7 +314,7 @@ long getCurrentLineNumber() {
314314 */
315315 int readEscape () throws IOException {
316316 // the escape char has just been read (normally a backslash)
317- final int ch = in .read ();
317+ final int ch = reader .read ();
318318 switch (ch ) {
319319 case 'r' :
320320 return CR ;
@@ -361,15 +361,15 @@ void trimTrailingSpaces(final StringBuilder buffer) {
361361 */
362362 boolean readEndOfLine (int ch ) throws IOException {
363363 // check if we have \r\n...
364- if (ch == CR && in .lookAhead () == LF ) {
364+ if (ch == CR && reader .lookAhead () == LF ) {
365365 // note: does not change ch outside of this method!
366- ch = in .read ();
366+ ch = reader .read ();
367367 }
368368 return ch == LF || ch == CR ;
369369 }
370370
371371 boolean isClosed () {
372- return in .isClosed ();
372+ return reader .isClosed ();
373373 }
374374
375375 /**
@@ -426,6 +426,6 @@ private boolean isMetaChar(final int ch) {
426426 * If an I/O error occurs
427427 */
428428 void close () throws IOException {
429- in .close ();
429+ reader .close ();
430430 }
431431}
0 commit comments