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:
parent
4dfc8ed074
commit
0d63758e09
|
@ -124,20 +124,17 @@ public class CSVPrinter {
|
||||||
|
|
||||||
public void print(char[] value, int offset, int len, boolean checkForEscape) throws IOException {
|
public void print(char[] value, int offset, int len, boolean checkForEscape) throws IOException {
|
||||||
if (!checkForEscape) {
|
if (!checkForEscape) {
|
||||||
if (newLine) {
|
printSep();
|
||||||
newLine = false;
|
|
||||||
} else {
|
|
||||||
out.write(this.strategy.getDelimiter());
|
|
||||||
}
|
|
||||||
out.write(value, offset, len);
|
out.write(value, offset, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strategy.getEncapsulator() != (char)-2) {
|
if (strategy.getEncapsulator() != CSVStrategy.ENCAPSULATOR_DISABLED) {
|
||||||
printAndEncapsulate(value, offset, len);
|
printAndEncapsulate(value, offset, len);
|
||||||
} else if (strategy.getEscape() != (char)-2) {
|
} else if (strategy.getEscape() != CSVStrategy.ESCAPE_DISABLED) {
|
||||||
printAndEscape(value, offset, len);
|
printAndEscape(value, offset, len);
|
||||||
} else {
|
} else {
|
||||||
|
printSep();
|
||||||
out.write(value, offset, len);
|
out.write(value, offset, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,11 +152,11 @@ public class CSVPrinter {
|
||||||
int pos = offset;
|
int pos = offset;
|
||||||
int end = offset + len;
|
int end = offset + len;
|
||||||
|
|
||||||
|
printSep();
|
||||||
|
|
||||||
char delim = this.strategy.getDelimiter();
|
char delim = this.strategy.getDelimiter();
|
||||||
char escape = this.strategy.getEscape();
|
char escape = this.strategy.getEscape();
|
||||||
|
|
||||||
printSep();
|
|
||||||
|
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
char c = value[pos];
|
char c = value[pos];
|
||||||
if (c == '\r' || c=='\n' || c==delim || c==escape) {
|
if (c == '\r' || c=='\n' || c==delim || c==escape) {
|
||||||
|
@ -194,11 +191,11 @@ public class CSVPrinter {
|
||||||
int pos = offset;
|
int pos = offset;
|
||||||
int end = offset + len;
|
int end = offset + len;
|
||||||
|
|
||||||
|
printSep();
|
||||||
|
|
||||||
char delim = this.strategy.getDelimiter();
|
char delim = this.strategy.getDelimiter();
|
||||||
char encapsulator = this.strategy.getEncapsulator();
|
char encapsulator = this.strategy.getEncapsulator();
|
||||||
|
|
||||||
printSep();
|
|
||||||
|
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
// always quote an empty token that is the first
|
// always quote an empty token that is the first
|
||||||
// on the line, as it may be the only thing on the
|
// 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 {
|
public void print(String value, boolean checkForEscape) throws IOException {
|
||||||
if (!checkForEscape) {
|
if (!checkForEscape) {
|
||||||
// write directly from string
|
// write directly from string
|
||||||
|
printSep();
|
||||||
out.write(value);
|
out.write(value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue