You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/07/21 18:32:09 UTC

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

Author: britter
Date: Mon Jul 21 16:32:08 2014
New Revision: 1612344

URL: http://svn.apache.org/r1612344
Log:
Consistently rename Quote/QuotePolicy to QuoteMode

Added:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/QuoteMode.java
      - copied, changed from r1612336, commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Quote.java
Removed:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Quote.java
Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.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/CSVPrinterTest.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=1612344&r1=1612343&r2=1612344&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 Mon Jul 21 16:32:08 2014
@@ -148,7 +148,7 @@ public final class CSVFormat implements 
 
     private final char delimiter;
     private final Character quoteChar; // null if quoting is disabled
-    private final Quote quotePolicy;
+    private final QuoteMode quoteMode;
     private final Character commentStart; // null if commenting is disabled
     private final Character escape; // null if escaping is disabled
     private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
@@ -313,8 +313,8 @@ public final class CSVFormat implements 
      *            the char used for value separation, must not be a line break character
      * @param quoteChar
      *            the Character used as value encapsulation marker, may be {@code null} to disable
-     * @param quotePolicy
-     *            the quote policy
+     * @param quoteMode
+     *            the quote mode
      * @param commentStart
      *            the Character used for comment identification, may be {@code null} to disable
      * @param escape
@@ -334,7 +334,7 @@ public final class CSVFormat implements 
      * @throws IllegalArgumentException if the delimiter is a line break character
      */
     private CSVFormat(final char delimiter, final Character quoteChar,
-            final Quote quotePolicy, final Character commentStart,
+            final QuoteMode quoteMode, final Character commentStart,
             final Character escape, final boolean ignoreSurroundingSpaces,
             final boolean ignoreEmptyLines, final String recordSeparator,
             final String nullString, final String[] header, final boolean skipHeaderRecord,
@@ -344,7 +344,7 @@ public final class CSVFormat implements 
         }
         this.delimiter = delimiter;
         this.quoteChar = quoteChar;
-        this.quotePolicy = quotePolicy;
+        this.quoteMode = quoteMode;
         this.commentStart = commentStart;
         this.escape = escape;
         this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
@@ -384,7 +384,7 @@ public final class CSVFormat implements 
         if (delimiter != other.delimiter) {
             return false;
         }
-        if (quotePolicy != other.quotePolicy) {
+        if (quoteMode != other.quoteMode) {
             return false;
         }
         if (quoteChar == null) {
@@ -552,8 +552,8 @@ public final class CSVFormat implements 
      *
      * @return the quote policy
      */
-    public Quote getQuotePolicy() {
-        return quotePolicy;
+    public QuoteMode getQuoteMode() {
+        return quoteMode;
     }
 
     /**
@@ -581,7 +581,7 @@ public final class CSVFormat implements 
         int result = 1;
 
         result = prime * result + delimiter;
-        result = prime * result + ((quotePolicy == null) ? 0 : quotePolicy.hashCode());
+        result = prime * result + ((quoteMode == null) ? 0 : quoteMode.hashCode());
         result = prime * result + ((quoteChar == null) ? 0 : quoteChar.hashCode());
         result = prime * result + ((commentStart == null) ? 0 : commentStart.hashCode());
         result = prime * result + ((escape == null) ? 0 : escape.hashCode());
@@ -735,7 +735,7 @@ public final class CSVFormat implements 
                     "The comment start and the escape character cannot be the same ('" + commentStart + "')");
         }
 
-        if (escape == null && quotePolicy == Quote.NONE) {
+        if (escape == null && quoteMode == QuoteMode.NONE) {
             throw new IllegalArgumentException("No quotes mode set but no escape character is set");
         }
     }
@@ -770,7 +770,7 @@ public final class CSVFormat implements 
         if (isLineBreak(commentMarker)) {
             throw new IllegalArgumentException("The comment start marker character cannot be a line break");
         }
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentMarker, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentMarker, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -788,7 +788,7 @@ public final class CSVFormat implements 
         if (isLineBreak(delimiter)) {
             throw new IllegalArgumentException("The delimiter cannot be a line break");
         }
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -819,7 +819,7 @@ public final class CSVFormat implements 
         if (isLineBreak(escape)) {
             throw new IllegalArgumentException("The escape character cannot be a line break");
         }
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -842,7 +842,7 @@ public final class CSVFormat implements 
      * @see #withSkipHeaderRecord(boolean)
      */
     public CSVFormat withHeader(final String... header) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -856,7 +856,7 @@ public final class CSVFormat implements 
      * @return A new CSVFormat that is equal to this but with the specified missing column names behavior.
      */
     public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNames) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -870,7 +870,7 @@ public final class CSVFormat implements 
      * @return A new CSVFormat that is equal to this but with the specified empty line skipping behavior.
      */
     public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -884,7 +884,7 @@ public final class CSVFormat implements 
      * @return A new CSVFormat that is equal to this but with the specified trimming behavior.
      */
     public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -905,7 +905,7 @@ public final class CSVFormat implements 
      * @return A new CSVFormat that is equal to this but with the specified null conversion string.
      */
     public CSVFormat withNullString(final String nullString) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -936,7 +936,7 @@ public final class CSVFormat implements 
         if (isLineBreak(quoteChar)) {
             throw new IllegalArgumentException("The quoteChar cannot be a line break");
         }
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -944,13 +944,13 @@ public final class CSVFormat implements 
     /**
      * Sets the output quote policy of the format to the specified value.
      *
-     * @param quotePolicy
+     * @param quoteModePolicy
      *            the quote policy to use for output.
      *
      * @return A new CSVFormat that is equal to this but with the specified quote policy
      */
-    public CSVFormat withQuotePolicy(final Quote quotePolicy) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+    public CSVFormat withQuoteMode(final QuoteMode quoteModePolicy) {
+        return new CSVFormat(delimiter, quoteChar, quoteModePolicy, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -984,7 +984,7 @@ public final class CSVFormat implements 
      *              if recordSeparator is none of CR, LF or CRLF
      */
     public CSVFormat withRecordSeparator(final String recordSeparator) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }
@@ -999,7 +999,7 @@ public final class CSVFormat implements 
      * @see #withHeader(String...)
      */
     public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
-        return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
+        return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
                 ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
                 allowMissingColumnNames);
     }

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java?rev=1612344&r1=1612343&r2=1612344&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java Mon Jul 21 16:32:08 2014
@@ -182,11 +182,11 @@ public final class CSVPrinter implements
         final char delimChar = format.getDelimiter();
         final char quoteChar = format.getQuoteChar().charValue();
 
-        Quote quotePolicy = format.getQuotePolicy();
-        if (quotePolicy == null) {
-            quotePolicy = Quote.MINIMAL;
+        QuoteMode quoteModePolicy = format.getQuoteMode();
+        if (quoteModePolicy == null) {
+            quoteModePolicy = QuoteMode.MINIMAL;
         }
-        switch (quotePolicy) {
+        switch (quoteModePolicy) {
         case ALL:
             quote = true;
             break;
@@ -248,7 +248,7 @@ public final class CSVPrinter implements
             }
             break;
         default:
-            throw new IllegalStateException("Unexpected Quote value: " + quotePolicy);
+            throw new IllegalStateException("Unexpected Quote value: " + quoteModePolicy);
         }
 
         if (!quote) {

Copied: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/QuoteMode.java (from r1612336, commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Quote.java)
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/QuoteMode.java?p2=commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/QuoteMode.java&p1=commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Quote.java&r1=1612336&r2=1612344&rev=1612344&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Quote.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/QuoteMode.java Mon Jul 21 16:32:08 2014
@@ -21,7 +21,7 @@ package org.apache.commons.csv;
  *
  * @version $Id$
  */
-public enum Quote {
+public enum QuoteMode {
 
     /**
      * Quotes all fields.

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=1612344&r1=1612343&r2=1612344&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 Mon Jul 21 16:32:08 2014
@@ -88,7 +88,7 @@ public class CSVFormatTest {
         final CSVFormat right = CSVFormat.newFormat('\'')
                 .withQuoteChar('"')
                 .withCommentMarker('#')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withCommentMarker('!');
 
@@ -109,7 +109,7 @@ public class CSVFormatTest {
                 .withQuoteChar('"')
                 .withCommentMarker('#')
                 .withEscape('+')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withEscape('!');
 
@@ -126,7 +126,7 @@ public class CSVFormatTest {
                 .withIgnoreEmptyLines(true)
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withHeader("Three", "Two", "One");
 
@@ -141,7 +141,7 @@ public class CSVFormatTest {
                 .withIgnoreEmptyLines(true)
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withIgnoreEmptyLines(false);
 
@@ -155,7 +155,7 @@ public class CSVFormatTest {
                 .withEscape('+')
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withIgnoreSurroundingSpaces(false);
 
@@ -174,9 +174,9 @@ public class CSVFormatTest {
     public void testEqualsQuotePolicy() {
         final CSVFormat right = CSVFormat.newFormat('\'')
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
-                .withQuotePolicy(Quote.MINIMAL);
+                .withQuoteMode(QuoteMode.MINIMAL);
 
         assertNotEquals(right, left);
     }
@@ -190,7 +190,7 @@ public class CSVFormatTest {
                 .withIgnoreEmptyLines(true)
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL);
+                .withQuoteMode(QuoteMode.ALL);
         final CSVFormat left = right
                 .withRecordSeparator(LF);
 
@@ -206,7 +206,7 @@ public class CSVFormatTest {
                 .withIgnoreEmptyLines(true)
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL)
+                .withQuoteMode(QuoteMode.ALL)
                 .withNullString("null");
         final CSVFormat left = right
                 .withNullString("---");
@@ -223,7 +223,7 @@ public class CSVFormatTest {
                 .withIgnoreEmptyLines(true)
                 .withIgnoreSurroundingSpaces(true)
                 .withQuoteChar('"')
-                .withQuotePolicy(Quote.ALL)
+                .withQuoteMode(QuoteMode.ALL)
                 .withNullString("null")
                 .withSkipHeaderRecord(true);
         final CSVFormat left = right
@@ -291,7 +291,7 @@ public class CSVFormatTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testQuotePolicyNoneWithoutEscapeThrowsException() {
-        CSVFormat.newFormat('!').withQuotePolicy(Quote.NONE);
+        CSVFormat.newFormat('!').withQuoteMode(QuoteMode.NONE);
     }
 
     @Test
@@ -301,7 +301,7 @@ public class CSVFormatTest {
         assertEquals(null, RFC4180.getEscape());
         assertFalse(RFC4180.getIgnoreEmptyLines());
         assertEquals(Character.valueOf('"'), RFC4180.getQuoteChar());
-        assertEquals(null, RFC4180.getQuotePolicy());
+        assertEquals(null, RFC4180.getQuoteMode());
         assertEquals("\r\n", RFC4180.getRecordSeparator());
     }
 
@@ -405,8 +405,8 @@ public class CSVFormatTest {
 
     @Test
     public void testWithQuotePolicy() throws Exception {
-        final CSVFormat formatWithQuotePolicy = CSVFormat.DEFAULT.withQuotePolicy(Quote.ALL);
-        assertEquals(Quote.ALL, formatWithQuotePolicy.getQuotePolicy());
+        final CSVFormat formatWithQuotePolicy = CSVFormat.DEFAULT.withQuoteMode(QuoteMode.ALL);
+        assertEquals(QuoteMode.ALL, formatWithQuotePolicy.getQuoteMode());
     }
 
     @Test

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1612344&r1=1612343&r2=1612344&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Mon Jul 21 16:32:08 2014
@@ -352,7 +352,7 @@ public class CSVPrinterTest {
     @Test
     public void testQuoteAll() throws IOException {
         final StringWriter sw = new StringWriter();
-        final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.ALL));
+        final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteMode(QuoteMode.ALL));
         printer.printRecord("a", "b\nc", "d");
         assertEquals("\"a\",\"b\nc\",\"d\"" + recordSeparator, sw.toString());
         printer.close();
@@ -361,7 +361,7 @@ public class CSVPrinterTest {
     @Test
     public void testQuoteNonNumeric() throws IOException {
         final StringWriter sw = new StringWriter();
-        final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.NON_NUMERIC));
+        final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteMode(QuoteMode.NON_NUMERIC));
         printer.printRecord("a", "b\nc", Integer.valueOf(1));
         assertEquals("\"a\",\"b\nc\",1" + recordSeparator, sw.toString());
         printer.close();
@@ -417,7 +417,7 @@ public class CSVPrinterTest {
     @Test
     public void testDelimeterQuoteNONE() throws IOException {
         final StringWriter sw = new StringWriter();
-        final CSVFormat format = CSVFormat.DEFAULT.withEscape('!').withQuotePolicy(Quote.NONE);
+        final CSVFormat format = CSVFormat.DEFAULT.withEscape('!').withQuoteMode(QuoteMode.NONE);
         final CSVPrinter printer = new CSVPrinter(sw, format);
         printer.print("a,b,c");
         printer.print("xyz");