commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
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 GMT
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<String, Integer> headerMap;
 
-    private final CSVLexer lexer;
+    private final Lexer lexer;
 
     /** A record buffer for getRecord(). Grows as necessary and is reused. */
     private final List<String> record = new ArrayList<String>();
@@ -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 <esc>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 <esc>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 <esc>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<CSVLexer> getLexerCtor(final String clazz) throws Exception
{
+   private static Constructor<Lexer> getLexerCtor(final String clazz) throws Exception
{
        @SuppressWarnings("unchecked")
-       final Class<CSVLexer> lexer = (Class<CSVLexer>) Class.forName("org.apache.commons.csv."
+ clazz);
+       final Class<Lexer> lexer = (Class<Lexer>) 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;



Mime
View raw message