Add code and test for Quote.NONE
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1480499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bb3bb0d65b
commit
512e446d28
|
@ -242,7 +242,9 @@ public class CSVPrinter implements Flushable, Closeable {
|
||||||
quote = !(object instanceof Number);
|
quote = !(object instanceof Number);
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
throw new IllegalArgumentException("Not implemented yet");
|
// Use the existing escaping code
|
||||||
|
printAndEscape(value, offset, len);
|
||||||
|
return;
|
||||||
case MINIMAL:
|
case MINIMAL:
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
// always quote an empty token that is the first
|
// always quote an empty token that is the first
|
||||||
|
|
|
@ -381,6 +381,17 @@ public class CSVPrinterTest {
|
||||||
printer.close();
|
printer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelimeterQuoteNONE() throws IOException {
|
||||||
|
final StringWriter sw = new StringWriter();
|
||||||
|
final CSVFormat format = CSVFormat.newBuilder().withEscape('!').withQuotePolicy(Quote.NONE).build();
|
||||||
|
final CSVPrinter printer = new CSVPrinter(sw, format);
|
||||||
|
printer.print("a,b,c");
|
||||||
|
printer.print("xyz");
|
||||||
|
assertEquals("a!,b!,c,xyz", sw.toString());
|
||||||
|
printer.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEOLQuoted() throws IOException {
|
public void testEOLQuoted() throws IOException {
|
||||||
final StringWriter sw = new StringWriter();
|
final StringWriter sw = new StringWriter();
|
||||||
|
|
Loading…
Reference in New Issue