SANDBOX-322: remember to print separators everywhere

git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@966014 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-07-20 21:16:37 +00:00
parent 4dfc8ed074
commit 0d63758e09
1 changed files with 9 additions and 11 deletions

View File

@ -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;
}