@@ -52,14 +52,14 @@ public void setUp() {
5252 formatWithEscaping = CSVFormat .DEFAULT .withEscape ('\\' );
5353 }
5454
55- private CSVLexer getLexer (final String input , final CSVFormat format ) {
56- return new CSVLexer (format , new ExtendedBufferedReader (new StringReader (input )));
55+ private Lexer getLexer (final String input , final CSVFormat format ) {
56+ return new Lexer (format , new ExtendedBufferedReader (new StringReader (input )));
5757 }
5858
5959 @ Test
6060 public void testSurroundingSpacesAreDeleted () throws IOException {
6161 final String code = "noSpaces, leadingSpaces,trailingSpaces , surroundingSpaces , ,," ;
62- final CSVLexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
62+ final Lexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
6363 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "noSpaces" ));
6464 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "leadingSpaces" ));
6565 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "trailingSpaces" ));
@@ -72,7 +72,7 @@ public void testSurroundingSpacesAreDeleted() throws IOException {
7272 @ Test
7373 public void testSurroundingTabsAreDeleted () throws IOException {
7474 final String code = "noTabs,\t leadingTab,trailingTab\t ,\t surroundingTabs\t ,\t \t ,," ;
75- final CSVLexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
75+ final Lexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
7676 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "noTabs" ));
7777 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "leadingTab" ));
7878 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "trailingTab" ));
@@ -99,7 +99,7 @@ public void testIgnoreEmptyLines() throws IOException {
9999 "\n " +
100100 "\n " ;
101101 final CSVFormat format = CSVFormat .DEFAULT .withIgnoreEmptyLines (true );
102- final CSVLexer parser = getLexer (code , format );
102+ final Lexer parser = getLexer (code , format );
103103
104104 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "first" ));
105105 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "line" ));
@@ -123,7 +123,7 @@ public void testComments() throws IOException {
123123 "# penultimate comment\n " +
124124 "# Final comment\n " ;
125125 final CSVFormat format = CSVFormat .DEFAULT .withCommentStart ('#' );
126- final CSVLexer parser = getLexer (code , format );
126+ final Lexer parser = getLexer (code , format );
127127
128128 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "first" ));
129129 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "line" ));
@@ -161,7 +161,7 @@ public void testCommentsAndEmptyLines() throws IOException {
161161 final CSVFormat format = CSVFormat .DEFAULT .withCommentStart ('#' ).withIgnoreEmptyLines (false );
162162 assertFalse ("Should not ignore empty lines" , format .getIgnoreEmptyLines ());
163163
164- final CSVLexer parser = getLexer (code , format );
164+ final Lexer parser = getLexer (code , format );
165165
166166
167167 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "1" ));
@@ -199,7 +199,7 @@ public void testBackslashWithoutEscaping() throws IOException {
199199 final String code = "a,\\ ,,b\\ \n \\ ,," ;
200200 final CSVFormat format = CSVFormat .DEFAULT ;
201201 assertFalse (format .isEscaping ());
202- final CSVLexer parser = getLexer (code , format );
202+ final Lexer parser = getLexer (code , format );
203203
204204 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "a" ));
205205 // an unquoted single backslash is not an escape char
@@ -221,7 +221,7 @@ public void testBackslashWithEscaping() throws IOException {
221221 final String code = "a,\\ ,,b\\ \\ \n \\ ,,\\ \n c,d\\ \r \n e" ;
222222 final CSVFormat format = formatWithEscaping .withIgnoreEmptyLines (false );
223223 assertTrue (format .isEscaping ());
224- final CSVLexer parser = getLexer (code , format );
224+ final Lexer parser = getLexer (code , format );
225225
226226 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "a" ));
227227 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "," ));
@@ -241,7 +241,7 @@ public void testNextToken4() throws IOException {
241241 * a, " foo " ,b
242242 */
243243 final String code = "a,\" foo\" ,b\n a, \" foo\" ,b\n a,\" foo \" ,b\n a, \" foo \" ,b" ;
244- final CSVLexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
244+ final Lexer parser = getLexer (code , CSVFormat .DEFAULT .withIgnoreSurroundingSpaces (true ));
245245 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "a" ));
246246 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "foo" ));
247247 assertThat (parser .nextToken (new Token ()), matches (EORECORD , "b" ));
@@ -261,7 +261,7 @@ public void testNextToken4() throws IOException {
261261 @ Test
262262 public void testNextToken5 () throws IOException {
263263 final String code = "a,\" foo\n \" ,b\n \" foo\n baar ,,,\" \n \" \n \t \n \" " ;
264- final CSVLexer parser = getLexer (code , CSVFormat .DEFAULT );
264+ final Lexer parser = getLexer (code , CSVFormat .DEFAULT );
265265 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "a" ));
266266 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "foo\n " ));
267267 assertThat (parser .nextToken (new Token ()), matches (EORECORD , "b" ));
@@ -280,7 +280,7 @@ public void testNextToken6() throws IOException {
280280 */
281281 final String code = "a;'b and '' more\n '\n !comment;;;;\n ;;" ;
282282 final CSVFormat format = CSVFormat .DEFAULT .withQuoteChar ('\'' ).withCommentStart ('!' ).withDelimiter (';' );
283- final CSVLexer parser = getLexer (code , format );
283+ final Lexer parser = getLexer (code , format );
284284 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "a" ));
285285 assertThat (parser .nextToken (new Token ()), matches (EORECORD , "b and ' more\n " ));
286286 }
@@ -289,7 +289,7 @@ public void testNextToken6() throws IOException {
289289 @ Test
290290 public void testDelimiterIsWhitespace () throws IOException {
291291 final String code = "one\t two\t \t four \t five\t six" ;
292- final CSVLexer parser = getLexer (code , CSVFormat .TDF );
292+ final Lexer parser = getLexer (code , CSVFormat .TDF );
293293 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "one" ));
294294 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "two" ));
295295 assertThat (parser .nextToken (new Token ()), matches (TOKEN , "" ));
@@ -300,96 +300,96 @@ public void testDelimiterIsWhitespace() throws IOException {
300300
301301 @ Test
302302 public void testEscapedCR () throws Exception {
303- final CSVLexer lexer = getLexer ("character\\ " + CR + "Escaped" , formatWithEscaping );
303+ final Lexer lexer = getLexer ("character\\ " + CR + "Escaped" , formatWithEscaping );
304304 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + CR + "Escaped" ));
305305 }
306306
307307 @ Test
308308 public void testCR () throws Exception {
309- final CSVLexer lexer = getLexer ("character" + CR + "NotEscaped" , formatWithEscaping );
309+ final Lexer lexer = getLexer ("character" + CR + "NotEscaped" , formatWithEscaping );
310310 assertThat (lexer .nextToken (new Token ()), hasContent ("character" ));
311311 assertThat (lexer .nextToken (new Token ()), hasContent ("NotEscaped" ));
312312 }
313313
314314 @ Test
315315 public void testEscapedLF () throws Exception {
316- final CSVLexer lexer = getLexer ("character\\ " + LF + "Escaped" , formatWithEscaping );
316+ final Lexer lexer = getLexer ("character\\ " + LF + "Escaped" , formatWithEscaping );
317317 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + LF + "Escaped" ));
318318 }
319319
320320 @ Test
321321 public void testLF () throws Exception {
322- final CSVLexer lexer = getLexer ("character" + LF + "NotEscaped" , formatWithEscaping );
322+ final Lexer lexer = getLexer ("character" + LF + "NotEscaped" , formatWithEscaping );
323323 assertThat (lexer .nextToken (new Token ()), hasContent ("character" ));
324324 assertThat (lexer .nextToken (new Token ()), hasContent ("NotEscaped" ));
325325 }
326326
327327 @ Test // TODO is this correct? Do we expect <esc>TAB to be unescaped?
328328 public void testEscapedTab () throws Exception {
329- final CSVLexer lexer = getLexer ("character\\ " + TAB + "Escaped" , formatWithEscaping );
329+ final Lexer lexer = getLexer ("character\\ " + TAB + "Escaped" , formatWithEscaping );
330330 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + TAB + "Escaped" ));
331331 }
332332
333333 @ Test
334334 public void testTab () throws Exception {
335- final CSVLexer lexer = getLexer ("character" + TAB + "NotEscaped" , formatWithEscaping );
335+ final Lexer lexer = getLexer ("character" + TAB + "NotEscaped" , formatWithEscaping );
336336 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + TAB + "NotEscaped" ));
337337 }
338338
339339 @ Test // TODO is this correct? Do we expect <esc>BACKSPACE to be unescaped?
340340 public void testEscapedBackspace () throws Exception {
341- final CSVLexer lexer = getLexer ("character\\ " + BACKSPACE + "Escaped" , formatWithEscaping );
341+ final Lexer lexer = getLexer ("character\\ " + BACKSPACE + "Escaped" , formatWithEscaping );
342342 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + BACKSPACE + "Escaped" ));
343343 }
344344
345345 @ Test
346346 public void testBackspace () throws Exception {
347- final CSVLexer lexer = getLexer ("character" + BACKSPACE + "NotEscaped" , formatWithEscaping );
347+ final Lexer lexer = getLexer ("character" + BACKSPACE + "NotEscaped" , formatWithEscaping );
348348 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + BACKSPACE + "NotEscaped" ));
349349 }
350350
351351 @ Test // TODO is this correct? Do we expect <esc>FF to be unescaped?
352352 public void testEscapedFF () throws Exception {
353- final CSVLexer lexer = getLexer ("character\\ " + FF + "Escaped" , formatWithEscaping );
353+ final Lexer lexer = getLexer ("character\\ " + FF + "Escaped" , formatWithEscaping );
354354 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + FF + "Escaped" ));
355355 }
356356
357357 @ Test
358358 public void testFF () throws Exception {
359- final CSVLexer lexer = getLexer ("character" + FF + "NotEscaped" , formatWithEscaping );
359+ final Lexer lexer = getLexer ("character" + FF + "NotEscaped" , formatWithEscaping );
360360 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + FF + "NotEscaped" ));
361361 }
362362
363363 @ Test
364364 public void testEscapedMySqlNullValue () throws Exception {
365365 // MySQL uses \N to symbolize null values. We have to restore this
366- final CSVLexer lexer = getLexer ("character\\ NEscaped" , formatWithEscaping );
366+ final Lexer lexer = getLexer ("character\\ NEscaped" , formatWithEscaping );
367367 assertThat (lexer .nextToken (new Token ()), hasContent ("character\\ NEscaped" ));
368368 }
369369
370370 @ Test
371371 public void testEscapedCharacter () throws Exception {
372- final CSVLexer lexer = getLexer ("character\\ aEscaped" , formatWithEscaping );
372+ final Lexer lexer = getLexer ("character\\ aEscaped" , formatWithEscaping );
373373 assertThat (lexer .nextToken (new Token ()), hasContent ("character\\ aEscaped" ));
374374 }
375375
376376 @ Test
377377 public void testEscapedControlCharacter () throws Exception {
378378 // we are explicitly using an escape different from \ here
379- final CSVLexer lexer = getLexer ("character!rEscaped" , CSVFormat .DEFAULT .withEscape ('!' ));
379+ final Lexer lexer = getLexer ("character!rEscaped" , CSVFormat .DEFAULT .withEscape ('!' ));
380380 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + CR + "Escaped" ));
381381 }
382382
383383 @ Test
384384 public void testEscapedControlCharacter2 () throws Exception {
385- final CSVLexer lexer = getLexer ("character\\ rEscaped" , CSVFormat .DEFAULT .withEscape ('\\' ));
385+ final Lexer lexer = getLexer ("character\\ rEscaped" , CSVFormat .DEFAULT .withEscape ('\\' ));
386386 assertThat (lexer .nextToken (new Token ()), hasContent ("character" + CR + "Escaped" ));
387387 }
388388
389389 @ Test (expected = IOException .class )
390390 public void testEscapingAtEOF () throws Exception {
391391 final String code = "escaping at EOF is evil\\ " ;
392- final CSVLexer lexer = getLexer (code , formatWithEscaping );
392+ final Lexer lexer = getLexer (code , formatWithEscaping );
393393
394394 lexer .nextToken (new Token ());
395395 }
0 commit comments