Skip to content

Commit 65f6f1d

Browse files
committed
Package private classes are not prefixed with "CSV": CSVLexer -> Lexer.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1511462 13f79535-47bb-0310-9956-ffa450edef68
1 parent 643b628 commit 65f6f1d

4 files changed

Lines changed: 36 additions & 36 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public static CSVParser parseURL(URL url, Charset charset, final CSVFormat forma
217217
private final CSVFormat format;
218218
private final Map<String, Integer> headerMap;
219219

220-
private final CSVLexer lexer;
220+
private final Lexer lexer;
221221

222222
/** A record buffer for getRecord(). Grows as necessary and is reused. */
223223
private final List<String> record = new ArrayList<String>();
@@ -265,7 +265,7 @@ public CSVParser(final Reader input) throws IOException {
265265
public CSVParser(final Reader reader, final CSVFormat format) throws IOException {
266266
format.validate();
267267
this.format = format;
268-
this.lexer = new CSVLexer(format, new ExtendedBufferedReader(reader));
268+
this.lexer = new Lexer(format, new ExtendedBufferedReader(reader));
269269
this.headerMap = this.initializeHeader();
270270
}
271271

src/main/java/org/apache/commons/csv/CSVLexer.java renamed to src/main/java/org/apache/commons/csv/Lexer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
* @version $Id$
3939
*/
40-
final class CSVLexer {
40+
final class Lexer {
4141

4242
/**
4343
* Constant char to use for disabling comments, escapes and encapsulation. The value -2 is used because it
@@ -58,7 +58,7 @@ final class CSVLexer {
5858
private final ExtendedBufferedReader in;
5959

6060
/** INTERNAL API. but ctor needs to be called dynamically by PerformanceTest class */
61-
CSVLexer(final CSVFormat format, final ExtendedBufferedReader in) {
61+
Lexer(final CSVFormat format, final ExtendedBufferedReader in) {
6262
this.in = in;
6363
this.delimiter = format.getDelimiter();
6464
this.escape = mapNullToDisabled(format.getEscape());

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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,\tleadingTab,trailingTab\t,\tsurroundingTabs\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\\,,\\\nc,d\\\r\ne";
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\na, \" foo\",b\na,\"foo \" ,b\na, \" 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\ttwo\t\tfour \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
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ private static void testParseCommonsCSV() throws Exception {
224224
}
225225

226226

227-
private static Constructor<CSVLexer> getLexerCtor(final String clazz) throws Exception {
227+
private static Constructor<Lexer> getLexerCtor(final String clazz) throws Exception {
228228
@SuppressWarnings("unchecked")
229-
final Class<CSVLexer> lexer = (Class<CSVLexer>) Class.forName("org.apache.commons.csv." + clazz);
229+
final Class<Lexer> lexer = (Class<Lexer>) Class.forName("org.apache.commons.csv." + clazz);
230230
return lexer.getConstructor(new Class<?>[]{CSVFormat.class, ExtendedBufferedReader.class});
231231
}
232232

@@ -235,12 +235,12 @@ private static void testCSVLexer(final boolean newToken, final String test) thro
235235
String dynamic = "";
236236
for (int i = 0; i < max; i++) {
237237
final ExtendedBufferedReader input = new ExtendedBufferedReader(getReader());
238-
CSVLexer lexer = null;
238+
Lexer lexer = null;
239239
if (test.startsWith("CSVLexer")) {
240240
dynamic="!";
241241
lexer = getLexerCtor(test).newInstance(new Object[]{format, input});
242242
} else {
243-
lexer = new CSVLexer(format, input);
243+
lexer = new Lexer(format, input);
244244
}
245245
int count = 0;
246246
int fields = 0;

0 commit comments

Comments
 (0)