You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jo...@apache.org on 2010/09/30 14:48:59 UTC

svn commit: r1003046 - in /commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer: CSVConfig.java CSVWriter.java

Author: joehni
Date: Thu Sep 30 12:48:59 2010
New Revision: 1003046

URL: http://svn.apache.org/viewvc?rev=1003046&view=rev
Log:
Apply configurable row delimiter by Dmitry Drozdov (SANDBOX-329).

Modified:
    commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVConfig.java
    commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java

Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVConfig.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVConfig.java?rev=1003046&r1=1003045&r2=1003046&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVConfig.java (original)
+++ commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVConfig.java Thu Sep 30 12:48:59 2010
@@ -50,6 +50,8 @@ public class CSVConfig {
     private char fillChar = ' ';
     /** The seperator character. Defaults to , */
     private char delimiter = ',';
+    /** The row separator. Defaults to \n */
+    private String rowDelimiter = "\n";
     /** Should we ignore the delimiter. Defaults to false */
     private boolean ignoreDelimiter = false;
     /** the value delimiter. Defaults to " */
@@ -185,6 +187,21 @@ public class CSVConfig {
     }
 
     /**
+     * @return the rowDelimiter used.
+     */
+    public String getRowDelimiter() {
+        return rowDelimiter;
+    }
+
+    /**
+     * Set the rowDelimiter to use
+     * @param rowDelimiter the row delimiter character.
+     */
+    public void setRowDelimiter(String rowDelimiter) {
+        this.rowDelimiter = rowDelimiter;
+    }
+
+    /**
      * @return if the writer should ignore the delimiter character.
      */
     public boolean isDelimiterIgnored() {

Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java?rev=1003046&r1=1003045&r2=1003046&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java (original)
+++ commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java Thu Sep 30 12:48:59 2010
@@ -70,7 +70,7 @@ public class CSVWriter {
                     }
                 }
             }
-            sb.append("\n");
+            sb.append(config.getRowDelimiter());
             String line = sb.toString();
             writer.write(line);
         } catch(Exception e) {