commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1297136 - in /commons/sandbox/csv/trunk/src: main/java/org/apache/commons/csv/CSVPrinter.java test/java/org/apache/commons/csv/CSVPrinterTest.java
Date Mon, 05 Mar 2012 17:28:57 GMT
Author: ebourg
Date: Mon Mar  5 17:28:56 2012
New Revision: 1297136

URL: http://svn.apache.org/viewvc?rev=1297136&view=rev
Log:
Varargs for CSVPrinter.println()

Modified:
    commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
    commons/sandbox/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Modified: commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java?rev=1297136&r1=1297135&r2=1297136&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java (original)
+++ commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java Mon Mar
 5 17:28:56 2012
@@ -78,7 +78,7 @@ public class CSVPrinter {
      *
      * @param values values to be outputted.
      */
-    public void println(String[] values) throws IOException {
+    public void println(String... values) throws IOException {
         for (String value : values) {
             print(value);
         }

Modified: commons/sandbox/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1297136&r1=1297135&r2=1297136&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/sandbox/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Mon
Mar  5 17:28:56 2012
@@ -17,7 +17,6 @@
 package org.apache.commons.csv;
 
 import java.io.IOException;
-import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.Random;
 
@@ -33,72 +32,63 @@ public class CSVPrinterTest extends Test
     public void testPrinter1() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a", "b"};
-        printer.println(line1);
+        printer.println("a", "b");
         assertEquals("a,b" + lineSeparator, sw.toString());
     }
 
     public void testPrinter2() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a,b", "b"};
-        printer.println(line1);
+        printer.println("a,b", "b");
         assertEquals("\"a,b\",b" + lineSeparator, sw.toString());
     }
 
     public void testPrinter3() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a, b", "b "};
-        printer.println(line1);
+        printer.println("a, b", "b ");
         assertEquals("\"a, b\",\"b \"" + lineSeparator, sw.toString());
     }
 
     public void testPrinter4() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a", "b\"c"};
-        printer.println(line1);
+        printer.println("a", "b\"c");
         assertEquals("a,\"b\"\"c\"" + lineSeparator, sw.toString());
     }
 
     public void testPrinter5() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a", "b\nc"};
-        printer.println(line1);
+        printer.println("a", "b\nc");
         assertEquals("a,\"b\nc\"" + lineSeparator, sw.toString());
     }
 
     public void testPrinter6() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a", "b\r\nc"};
-        printer.println(line1);
+        printer.println("a", "b\r\nc");
         assertEquals("a,\"b\r\nc\"" + lineSeparator, sw.toString());
     }
 
     public void testPrinter7() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
-        String[] line1 = {"a", "b\\c"};
-        printer.println(line1);
+        printer.println("a", "b\\c");
         assertEquals("a,b\\c" + lineSeparator, sw.toString());
     }
 
     public void testExcelPrinter1() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-        String[] line1 = {"a", "b"};
-        printer.println(line1);
+        printer.println("a", "b");
         assertEquals("a,b" + lineSeparator, sw.toString());
     }
 
     public void testExcelPrinter2() throws IOException {
         StringWriter sw = new StringWriter();
         CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
-        String[] line1 = {"a,b", "b"};
-        printer.println(line1);
+        printer.println("a,b", "b");
         assertEquals("\"a,b\",b" + lineSeparator, sw.toString());
     }
 
@@ -172,9 +162,7 @@ public class CSVPrinterTest extends Test
         String result = sw.toString();
         // System.out.println("### :" + printable(result));
 
-        StringReader reader = new StringReader(result);
-
-        CSVParser parser = new CSVParser(reader, format);
+        CSVParser parser = new CSVParser(result, format);
         String[][] parseResult = parser.getRecords();
 
         if (!equals(lines, parseResult)) {



Mime
View raw message