Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 4ad7d63

Browse files
committed
work on #40
1 parent 2ce5d2c commit 4ad7d63

File tree

4 files changed

+11
-613
lines changed

4 files changed

+11
-613
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Version: 2.3.4 (xx-xxx-2014)
33

44
#38: Extra column delimiter added when column is escaped and follows empty column
55
(reported by Paul M, Magrath@github)
6+
- Allow sub-classing of `CsvWriter`
67

78
------------------------------------------------------------------------
89
=== History: ===

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvGenerator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,18 @@ private Feature(boolean defaultState) {
110110
public CsvGenerator(IOContext ctxt, int jsonFeatures, int csvFeatures,
111111
ObjectCodec codec, Writer out,
112112
char columnSeparator, char quoteChar, char[] linefeed)
113+
{
114+
this(ctxt, jsonFeatures, csvFeatures, codec,
115+
new CsvWriter(ctxt, out, columnSeparator, quoteChar, linefeed));
116+
}
117+
118+
public CsvGenerator(IOContext ctxt, int jsonFeatures, int csvFeatures,
119+
ObjectCodec codec, CsvWriter csvWriter)
113120
{
114121
super(jsonFeatures, codec);
115122
_ioContext = ctxt;
116123
_csvFeatures = csvFeatures;
117-
_writer = new CsvWriter(ctxt, out, columnSeparator, quoteChar, linefeed);
124+
_writer = csvWriter;
118125
}
119126

120127
/*

src/main/java/com/fasterxml/jackson/dataformat/csv/impl/CsvWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Low-level helper class that handles actual output of CSV, purely
1313
* based on indexes given without worrying about reordering etc.
1414
*/
15-
public final class CsvWriter
15+
public class CsvWriter
1616
{
1717
/* As an optimization we try coalescing short writes into
1818
* buffer; but pass longer directly.
@@ -568,7 +568,7 @@ public void close(boolean autoClose) throws IOException
568568
* Helper method that determines whether given String is likely
569569
* to require quoting; check tries to optimize for speed.
570570
*/
571-
protected final boolean _mayNeedQuotes(String value, int length)
571+
protected boolean _mayNeedQuotes(String value, int length)
572572
{
573573
// let's not bother checking long Strings, just quote already:
574574
if (length > MAX_QUOTE_CHECK) {

0 commit comments

Comments
 (0)