Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5965F10479 for ; Wed, 7 Aug 2013 20:00:57 +0000 (UTC) Received: (qmail 91739 invoked by uid 500); 7 Aug 2013 20:00:56 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 91622 invoked by uid 500); 7 Aug 2013 20:00:50 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 91612 invoked by uid 99); 7 Aug 2013 20:00:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Aug 2013 20:00:48 +0000 X-ASF-Spam-Status: No, hits=-1996.5 required=5.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Aug 2013 20:00:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E07982388A38; Wed, 7 Aug 2013 20:00:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1511462 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ Date: Wed, 07 Aug 2013 20:00:26 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130807200026.E07982388A38@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Wed Aug 7 20:00:26 2013 New Revision: 1511462 URL: http://svn.apache.org/r1511462 Log: Package private classes are not prefixed with "CSV": CSVLexer -> Lexer. Added: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java - copied, changed from r1511458, commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java Removed: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1511462&r1=1511461&r2=1511462&view=diff ============================================================================== --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java (original) +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java Wed Aug 7 20:00:26 2013 @@ -217,7 +217,7 @@ public final class CSVParser implements private final CSVFormat format; private final Map headerMap; - private final CSVLexer lexer; + private final Lexer lexer; /** A record buffer for getRecord(). Grows as necessary and is reused. */ private final List record = new ArrayList(); @@ -265,7 +265,7 @@ public final class CSVParser implements public CSVParser(final Reader reader, final CSVFormat format) throws IOException { format.validate(); this.format = format; - this.lexer = new CSVLexer(format, new ExtendedBufferedReader(reader)); + this.lexer = new Lexer(format, new ExtendedBufferedReader(reader)); this.headerMap = this.initializeHeader(); } Copied: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java (from r1511458, commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java) URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java?p2=commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java&p1=commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java&r1=1511458&r2=1511462&rev=1511462&view=diff ============================================================================== --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVLexer.java (original) +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java Wed Aug 7 20:00:26 2013 @@ -37,7 +37,7 @@ import java.io.IOException; * * @version $Id$ */ -final class CSVLexer { +final class Lexer { /** * Constant char to use for disabling comments, escapes and encapsulation. The value -2 is used because it @@ -58,7 +58,7 @@ final class CSVLexer { private final ExtendedBufferedReader in; /** INTERNAL API. but ctor needs to be called dynamically by PerformanceTest class */ - CSVLexer(final CSVFormat format, final ExtendedBufferedReader in) { + Lexer(final CSVFormat format, final ExtendedBufferedReader in) { this.in = in; this.delimiter = format.getDelimiter(); this.escape = mapNullToDisabled(format.getEscape()); Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java?rev=1511462&r1=1511461&r2=1511462&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java Wed Aug 7 20:00:26 2013 @@ -52,14 +52,14 @@ public class CSVLexerTest { formatWithEscaping = CSVFormat.DEFAULT.withEscape('\\'); } - private CSVLexer getLexer(final String input, final CSVFormat format) { - return new CSVLexer(format, new ExtendedBufferedReader(new StringReader(input))); + private Lexer getLexer(final String input, final CSVFormat format) { + return new Lexer(format, new ExtendedBufferedReader(new StringReader(input))); } @Test public void testSurroundingSpacesAreDeleted() throws IOException { final String code = "noSpaces, leadingSpaces,trailingSpaces , surroundingSpaces , ,,"; - final CSVLexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); + final Lexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); assertThat(parser.nextToken(new Token()), matches(TOKEN, "noSpaces")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "leadingSpaces")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "trailingSpaces")); @@ -72,7 +72,7 @@ public class CSVLexerTest { @Test public void testSurroundingTabsAreDeleted() throws IOException { final String code = "noTabs,\tleadingTab,trailingTab\t,\tsurroundingTabs\t,\t\t,,"; - final CSVLexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); + final Lexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); assertThat(parser.nextToken(new Token()), matches(TOKEN, "noTabs")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "leadingTab")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "trailingTab")); @@ -99,7 +99,7 @@ public class CSVLexerTest { "\n"+ "\n"; final CSVFormat format = CSVFormat.DEFAULT.withIgnoreEmptyLines(true); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "first")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "line")); @@ -123,7 +123,7 @@ public class CSVLexerTest { "# penultimate comment\n"+ "# Final comment\n"; final CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#'); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "first")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "line")); @@ -161,7 +161,7 @@ public class CSVLexerTest { final CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#').withIgnoreEmptyLines(false); assertFalse("Should not ignore empty lines", format.getIgnoreEmptyLines()); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "1")); @@ -199,7 +199,7 @@ public class CSVLexerTest { final String code = "a,\\,,b\\\n\\,,"; final CSVFormat format = CSVFormat.DEFAULT; assertFalse(format.isEscaping()); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "a")); // an unquoted single backslash is not an escape char @@ -221,7 +221,7 @@ public class CSVLexerTest { final String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne"; final CSVFormat format = formatWithEscaping.withIgnoreEmptyLines(false); assertTrue(format.isEscaping()); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "a")); assertThat(parser.nextToken(new Token()), matches(TOKEN, ",")); @@ -241,7 +241,7 @@ public class CSVLexerTest { * a, " foo " ,b */ final String code = "a,\"foo\",b\na, \" foo\",b\na,\"foo \" ,b\na, \" foo \" ,b"; - final CSVLexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); + final Lexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); assertThat(parser.nextToken(new Token()), matches(TOKEN, "a")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "foo")); assertThat(parser.nextToken(new Token()), matches(EORECORD, "b")); @@ -261,7 +261,7 @@ public class CSVLexerTest { @Test public void testNextToken5() throws IOException { final String code = "a,\"foo\n\",b\n\"foo\n baar ,,,\"\n\"\n\t \n\""; - final CSVLexer parser = getLexer(code, CSVFormat.DEFAULT); + final Lexer parser = getLexer(code, CSVFormat.DEFAULT); assertThat(parser.nextToken(new Token()), matches(TOKEN, "a")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "foo\n")); assertThat(parser.nextToken(new Token()), matches(EORECORD, "b")); @@ -280,7 +280,7 @@ public class CSVLexerTest { */ final String code = "a;'b and '' more\n'\n!comment;;;;\n;;"; final CSVFormat format = CSVFormat.DEFAULT.withQuoteChar('\'').withCommentStart('!').withDelimiter(';'); - final CSVLexer parser = getLexer(code, format); + final Lexer parser = getLexer(code, format); assertThat(parser.nextToken(new Token()), matches(TOKEN, "a")); assertThat(parser.nextToken(new Token()), matches(EORECORD, "b and ' more\n")); } @@ -289,7 +289,7 @@ public class CSVLexerTest { @Test public void testDelimiterIsWhitespace() throws IOException { final String code = "one\ttwo\t\tfour \t five\t six"; - final CSVLexer parser = getLexer(code, CSVFormat.TDF); + final Lexer parser = getLexer(code, CSVFormat.TDF); assertThat(parser.nextToken(new Token()), matches(TOKEN, "one")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "two")); assertThat(parser.nextToken(new Token()), matches(TOKEN, "")); @@ -300,96 +300,96 @@ public class CSVLexerTest { @Test public void testEscapedCR() throws Exception { - final CSVLexer lexer = getLexer("character\\" + CR + "Escaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\" + CR + "Escaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped")); } @Test public void testCR() throws Exception { - final CSVLexer lexer = getLexer("character" + CR + "NotEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character" + CR + "NotEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character")); assertThat(lexer.nextToken(new Token()), hasContent("NotEscaped")); } @Test public void testEscapedLF() throws Exception { - final CSVLexer lexer = getLexer("character\\" + LF + "Escaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\" + LF + "Escaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + LF + "Escaped")); } @Test public void testLF() throws Exception { - final CSVLexer lexer = getLexer("character" + LF + "NotEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character" + LF + "NotEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character")); assertThat(lexer.nextToken(new Token()), hasContent("NotEscaped")); } @Test // TODO is this correct? Do we expect TAB to be unescaped? public void testEscapedTab() throws Exception { - final CSVLexer lexer = getLexer("character\\" + TAB + "Escaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\" + TAB + "Escaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "Escaped")); } @Test public void testTab() throws Exception { - final CSVLexer lexer = getLexer("character" + TAB + "NotEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character" + TAB + "NotEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "NotEscaped")); } @Test // TODO is this correct? Do we expect BACKSPACE to be unescaped? public void testEscapedBackspace() throws Exception { - final CSVLexer lexer = getLexer("character\\" + BACKSPACE + "Escaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\" + BACKSPACE + "Escaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "Escaped")); } @Test public void testBackspace() throws Exception { - final CSVLexer lexer = getLexer("character" + BACKSPACE + "NotEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character" + BACKSPACE + "NotEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "NotEscaped")); } @Test // TODO is this correct? Do we expect FF to be unescaped? public void testEscapedFF() throws Exception { - final CSVLexer lexer = getLexer("character\\" + FF + "Escaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\" + FF + "Escaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + FF + "Escaped")); } @Test public void testFF() throws Exception { - final CSVLexer lexer = getLexer("character" + FF + "NotEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character" + FF + "NotEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character" + FF + "NotEscaped")); } @Test public void testEscapedMySqlNullValue() throws Exception { // MySQL uses \N to symbolize null values. We have to restore this - final CSVLexer lexer = getLexer("character\\NEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\NEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character\\NEscaped")); } @Test public void testEscapedCharacter() throws Exception { - final CSVLexer lexer = getLexer("character\\aEscaped", formatWithEscaping); + final Lexer lexer = getLexer("character\\aEscaped", formatWithEscaping); assertThat(lexer.nextToken(new Token()), hasContent("character\\aEscaped")); } @Test public void testEscapedControlCharacter() throws Exception { // we are explicitly using an escape different from \ here - final CSVLexer lexer = getLexer("character!rEscaped", CSVFormat.DEFAULT.withEscape('!')); + final Lexer lexer = getLexer("character!rEscaped", CSVFormat.DEFAULT.withEscape('!')); assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped")); } @Test public void testEscapedControlCharacter2() throws Exception { - final CSVLexer lexer = getLexer("character\\rEscaped", CSVFormat.DEFAULT.withEscape('\\')); + final Lexer lexer = getLexer("character\\rEscaped", CSVFormat.DEFAULT.withEscape('\\')); assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped")); } @Test(expected = IOException.class) public void testEscapingAtEOF() throws Exception { final String code = "escaping at EOF is evil\\"; - final CSVLexer lexer = getLexer(code, formatWithEscaping); + final Lexer lexer = getLexer(code, formatWithEscaping); lexer.nextToken(new Token()); } Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java?rev=1511462&r1=1511461&r2=1511462&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/PerformanceTest.java Wed Aug 7 20:00:26 2013 @@ -224,9 +224,9 @@ public class PerformanceTest { } - private static Constructor getLexerCtor(final String clazz) throws Exception { + private static Constructor getLexerCtor(final String clazz) throws Exception { @SuppressWarnings("unchecked") - final Class lexer = (Class) Class.forName("org.apache.commons.csv." + clazz); + final Class lexer = (Class) Class.forName("org.apache.commons.csv." + clazz); return lexer.getConstructor(new Class[]{CSVFormat.class, ExtendedBufferedReader.class}); } @@ -235,12 +235,12 @@ public class PerformanceTest { String dynamic = ""; for (int i = 0; i < max; i++) { final ExtendedBufferedReader input = new ExtendedBufferedReader(getReader()); - CSVLexer lexer = null; + Lexer lexer = null; if (test.startsWith("CSVLexer")) { dynamic="!"; lexer = getLexerCtor(test).newInstance(new Object[]{format, input}); } else { - lexer = new CSVLexer(format, input); + lexer = new Lexer(format, input); } int count = 0; int fields = 0;