commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1599285 - in /commons/proper/csv/trunk/src: changes/changes.xml main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVPrinterTest.java
Date Mon, 02 Jun 2014 18:04:50 GMT
Author: ggregory
Date: Mon Jun  2 18:04:49 2014
New Revision: 1599285

URL: http://svn.apache.org/r1599285
Log:
<action issue="CSV-119" type="add" dev="ggregory" due-to="Sergei Lebedev">CSVFormat
is missing a print(...) method</action>

Modified:
    commons/proper/csv/trunk/src/changes/changes.xml
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Modified: commons/proper/csv/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/changes/changes.xml?rev=1599285&r1=1599284&r2=1599285&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/changes/changes.xml (original)
+++ commons/proper/csv/trunk/src/changes/changes.xml Mon Jun  2 18:04:49 2014
@@ -40,6 +40,7 @@
   <body>
 
     <release version="1.0" date="TBD" description="First release">
+      <action issue="CSV-119" type="add" dev="ggregory" due-to="Sergei Lebedev">CSVFormat
is missing a print(...) method</action>
       <action issue="CSV-118" type="fix" dev="ggregory" due-to="Enrique Lara">CSVRecord.toMap()
throws NPE on formats with no
         headers.</action>
       <action issue="CSV-113" type="fix" dev="sebb">Check whether ISE/IAE are being
used appropriately</action>

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=1599285&r1=1599284&r2=1599285&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 Jun 
2 18:04:49 2014
@@ -595,6 +595,21 @@ public final class CSVFormat implements 
         return new CSVParser(in, this);
     }
 
+    /**
+     * Prints to the specified output.
+     * 
+     * <p>
+     * See also {@link CSVPrinter}.
+     * </p>
+     * 
+     * @param out
+     *        the output
+     * @return a printer to an output
+     */
+    public CSVPrinter print(final Appendable out) {
+        return new CSVPrinter(out, this);
+    }
+
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder();

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=1599285&r1=1599284&r2=1599285&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
Jun  2 18:04:49 2014
@@ -304,6 +304,15 @@ public class CSVPrinterTest {
     }
 
     @Test
+    public void testPrint() throws IOException {
+        final StringWriter sw = new StringWriter();
+        final CSVPrinter printer = CSVFormat.DEFAULT.print(sw);
+        printer.printRecord("a", "b\\c");
+        assertEquals("a,b\\c" + recordSeparator, sw.toString());
+        printer.close();
+    }
+
+    @Test
     public void testPrintNullValues() throws IOException {
         final StringWriter sw = new StringWriter();
         final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);



Mime
View raw message