Author: yonik Date: Tue Jul 20 21:16:37 2010 New Revision: 966014 URL: http://svn.apache.org/viewvc?rev=966014&view=rev Log: SANDBOX-322: remember to print separators everywhere
Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVPrinter.java Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVPrinter.java URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVPrinter.java?rev=966014&r1=966013&r2=966014&view=diff ============================================================================== --- commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVPrinter.java (original) +++ commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVPrinter.java Tue Jul 20 21:16:37 2010 @@ -124,20 +124,17 @@ public class CSVPrinter { public void print(char[] value, int offset, int len, boolean checkForEscape) throws IOException { if (!checkForEscape) { - if (newLine) { - newLine = false; - } else { - out.write(this.strategy.getDelimiter()); - } + printSep(); out.write(value, offset, len); return; } - if (strategy.getEncapsulator() != (char)-2) { + if (strategy.getEncapsulator() != CSVStrategy.ENCAPSULATOR_DISABLED) { printAndEncapsulate(value, offset, len); - } else if (strategy.getEscape() != (char)-2) { + } else if (strategy.getEscape() != CSVStrategy.ESCAPE_DISABLED) { printAndEscape(value, offset, len); } else { + printSep(); out.write(value, offset, len); } } @@ -155,11 +152,11 @@ public class CSVPrinter { int pos = offset; int end = offset + len; + printSep(); + char delim = this.strategy.getDelimiter(); char escape = this.strategy.getEscape(); - printSep(); - while (pos < end) { char c = value[pos]; if (c == '\r' || c=='\n' || c==delim || c==escape) { @@ -194,11 +191,11 @@ public class CSVPrinter { int pos = offset; int end = offset + len; + printSep(); + char delim = this.strategy.getDelimiter(); char encapsulator = this.strategy.getEncapsulator(); - printSep(); - if (len <= 0) { // always quote an empty token that is the first // on the line, as it may be the only thing on the @@ -285,6 +282,7 @@ public class CSVPrinter { public void print(String value, boolean checkForEscape) throws IOException { if (!checkForEscape) { // write directly from string + printSep(); out.write(value); return; }