You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/10/14 07:00:19 UTC

svn commit: r1398010 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/

Author: ggregory
Date: Sun Oct 14 05:00:19 2012
New Revision: 1398010

URL: http://svn.apache.org/viewvc?rev=1398010&view=rev
Log:
Rename "encapsulator" to "quoteChar" so we have quoteChar and quotePolicy. Encapsulator makes me want to ask "encapsulate what"? fieldEncapsulator would be better but so verbose, quoteChar feels more to the point to me and provides symmetry with quotePolicy.

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.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/CSVParserTest.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1398010&r1=1398009&r2=1398010&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Sun Oct 14 05:00:19 2012
@@ -66,7 +66,7 @@ public class CSVFormat implements Serial
     public static final CSVFormat DEFAULT =
             PRISTINE
             .withDelimiter(COMMA)
-            .withEncapsulator(DOUBLE_QUOTE)
+            .withQuoteChar(DOUBLE_QUOTE)
             .withIgnoreEmptyLines(true)
             .withLineSeparator(CRLF);
 
@@ -82,7 +82,7 @@ public class CSVFormat implements Serial
     public static final CSVFormat RFC4180 =
             PRISTINE
             .withDelimiter(COMMA)
-            .withEncapsulator(DOUBLE_QUOTE)
+            .withQuoteChar(DOUBLE_QUOTE)
             .withLineSeparator(CRLF);
 
     /**
@@ -98,14 +98,14 @@ public class CSVFormat implements Serial
     public static final CSVFormat EXCEL =
             PRISTINE
             .withDelimiter(COMMA)
-            .withEncapsulator(DOUBLE_QUOTE)
+            .withQuoteChar(DOUBLE_QUOTE)
             .withLineSeparator(CRLF);
 
     /** Tab-delimited format, with quote; leading and trailing spaces ignored. */
     public static final CSVFormat TDF =
             PRISTINE
             .withDelimiter(TAB)
-            .withEncapsulator(DOUBLE_QUOTE)
+            .withQuoteChar(DOUBLE_QUOTE)
             .withIgnoreSurroundingSpaces(true)
             .withIgnoreEmptyLines(true)
             .withLineSeparator(CRLF);
@@ -258,8 +258,8 @@ public class CSVFormat implements Serial
      * @throws IllegalArgumentException
      *             thrown if the specified character is a line break
      */
-    public CSVFormat withEncapsulator(final char encapsulator) {
-        return withEncapsulator(Character.valueOf(encapsulator));
+    public CSVFormat withQuoteChar(final char quoteChar) {
+        return withQuoteChar(Character.valueOf(quoteChar));
     }
 
     /**
@@ -271,11 +271,11 @@ public class CSVFormat implements Serial
      * @throws IllegalArgumentException
      *             thrown if the specified character is a line break
      */
-    public CSVFormat withEncapsulator(final Character encapsulator) {
-        if (isLineBreak(encapsulator)) {
+    public CSVFormat withQuoteChar(final Character quoteChar) {
+        if (isLineBreak(quoteChar)) {
             throw new IllegalArgumentException("The quoteChar cannot be a line break");
         }
-        return new CSVFormat(delimiter, encapsulator, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
     }
 

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java?rev=1398010&r1=1398009&r2=1398010&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java Sun Oct 14 05:00:19 2012
@@ -88,7 +88,7 @@ public class CSVFileParserTest {
         assertTrue(testName+" require 1 param", split.length >= 1);
          // first line starts with csv data file name
         final BufferedReader csvFile = new BufferedReader(new FileReader(new File(BASE, split[0])));
-        CSVFormat fmt = CSVFormat.PRISTINE.withDelimiter(',').withEncapsulator('"');
+        CSVFormat fmt = CSVFormat.PRISTINE.withDelimiter(',').withQuoteChar('"');
         boolean checkComments = false;
         for(int i=1; i < split.length; i++) {
             final String option = split[i];

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1398010&r1=1398009&r2=1398010&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java Sun Oct 14 05:00:19 2012
@@ -38,7 +38,7 @@ public class CSVFormatTest {
         final CSVFormat format = new CSVFormat('!', '!', Quote.MINIMAL, '!', '!', true, true, CRLF, null);
 
         format.withDelimiter('?');
-        format.withEncapsulator('?');
+        format.withQuoteChar('?');
         format.withCommentStart('?');
         format.withLineSeparator("?");
         format.withEscape('?');
@@ -63,7 +63,7 @@ public class CSVFormatTest {
         final CSVFormat format = new CSVFormat('!', '!', null, '!', '!', true, true, CRLF, null);
 
         assertEquals('?', format.withDelimiter('?').getDelimiter());
-        assertEquals('?', format.withEncapsulator('?').getQuoteChar().charValue());
+        assertEquals('?', format.withQuoteChar('?').getQuoteChar().charValue());
         assertEquals('?', format.withCommentStart('?').getCommentStart().charValue());
         assertEquals("?", format.withLineSeparator("?").getLineSeparator());
         assertEquals('?', format.withEscape('?').getEscape().charValue());
@@ -102,7 +102,7 @@ public class CSVFormatTest {
         }
 
         try {
-            format.withEncapsulator('\n');
+            format.withQuoteChar('\n');
             fail();
         } catch (final IllegalArgumentException e) {
             // expected
@@ -130,13 +130,13 @@ public class CSVFormatTest {
         }
 
         try {
-            format.withEncapsulator('!').withCommentStart('!').validate();
+            format.withQuoteChar('!').withCommentStart('!').validate();
             fail();
         } catch (final IllegalStateException e) {
             // expected
         }
 
-        format.withEncapsulator(null).withCommentStart(null).validate();
+        format.withQuoteChar(null).withCommentStart(null).validate();
 
         try {
             format.withEscape('!').withCommentStart('!').validate();
@@ -149,7 +149,7 @@ public class CSVFormatTest {
 
 
         try {
-            format.withEncapsulator('!').withDelimiter('!').validate();
+            format.withQuoteChar('!').withDelimiter('!').validate();
             fail();
         } catch (final IllegalStateException e) {
             // expected

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=1398010&r1=1398009&r2=1398010&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 Sun Oct 14 05:00:19 2012
@@ -259,7 +259,7 @@ public class CSVLexerTest {
         *       ;;
         */
         final String code = "a;'b and '' more\n'\n!comment;;;;\n;;";
-        final CSVFormat format = CSVFormat.DEFAULT.withDelimiter(';').withEncapsulator('\'').withCommentStart('!');
+        final CSVFormat format = CSVFormat.DEFAULT.withDelimiter(';').withQuoteChar('\'').withCommentStart('!');
         final Lexer parser = getLexer(code, format);
         assertTokenEquals(TOKEN, "a", parser.nextToken(new Token()));
         assertTokenEquals(EORECORD, "b and ' more\n", parser.nextToken(new Token()));

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1398010&r1=1398009&r2=1398010&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java Sun Oct 14 05:00:19 2012
@@ -309,7 +309,7 @@ public class CSVParserTest {
         };
 
 
-        final CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withEncapsulator('\'').withEscape('/')
+        final CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withQuoteChar('\'').withEscape('/')
                                .withIgnoreEmptyLines(true).withLineSeparator(CRLF);
 
         final CSVParser parser = new CSVParser(code, format);