Modified:
websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVFormat.java.html
==============================================================================
---
websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVFormat.java.html
(original)
+++
websites/production/commons/content/proper/commons-csv/jacoco/org.apache.commons.csv/CSVFormat.java.html
Wed Mar 19 22:20:06 2025
@@ -43,6 +43,7 @@ import java.util.function.Supplier;
import org.apache.commons.codec.binary.Base64OutputStream;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.function.IOStream;
import org.apache.commons.io.function.Uncheck;
import org.apache.commons.io.output.AppendableOutputStream;
@@ -209,12 +210,12 @@ public final class CSVFormat implements
*/
public static Builder create() {
// @formatter:off
-<span class="fc" id="L212"> return new Builder()</span>
-<span class="fc" id="L213">
.setDelimiter(Constants.COMMA)</span>
-<span class="fc" id="L214">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L215">
.setRecordSeparator(Constants.CRLF)</span>
-<span class="fc" id="L216">
.setIgnoreEmptyLines(true)</span>
-<span class="fc" id="L217">
.setDuplicateHeaderMode(DuplicateHeaderMode.ALLOW_ALL);</span>
+<span class="fc" id="L213"> return new Builder()</span>
+<span class="fc" id="L214">
.setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L215">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L216">
.setRecordSeparator(Constants.CRLF)</span>
+<span class="fc" id="L217">
.setIgnoreEmptyLines(true)</span>
+<span class="fc" id="L218">
.setDuplicateHeaderMode(DuplicateHeaderMode.ALLOW_ALL);</span>
// @formatter:on
}
@@ -225,7 +226,7 @@ public final class CSVFormat implements
* @return a new builder.
*/
public static Builder create(final CSVFormat csvFormat) {
-<span class="fc" id="L228"> return new Builder(csvFormat);</span>
+<span class="fc" id="L229"> return new Builder(csvFormat);</span>
}
private boolean allowMissingColumnNames;
@@ -270,33 +271,37 @@ public final class CSVFormat implements
private boolean trim;
+ /** The maximum number of rows to process, excluding the header row. */
+ private long maxRows;
+
private Builder() {
// empty
}
-<span class="fc" id="L277"> private Builder(final CSVFormat csvFormat)
{</span>
-<span class="fc" id="L278"> this.delimiter =
csvFormat.delimiter;</span>
-<span class="fc" id="L279"> this.quoteCharacter =
csvFormat.quoteCharacter;</span>
-<span class="fc" id="L280"> this.quoteMode =
csvFormat.quoteMode;</span>
-<span class="fc" id="L281"> this.commentMarker =
csvFormat.commentMarker;</span>
-<span class="fc" id="L282"> this.escapeCharacter =
csvFormat.escapeCharacter;</span>
-<span class="fc" id="L283"> this.ignoreSurroundingSpaces =
csvFormat.ignoreSurroundingSpaces;</span>
-<span class="fc" id="L284"> this.allowMissingColumnNames =
csvFormat.allowMissingColumnNames;</span>
-<span class="fc" id="L285"> this.ignoreEmptyLines =
csvFormat.ignoreEmptyLines;</span>
-<span class="fc" id="L286"> this.recordSeparator =
csvFormat.recordSeparator;</span>
-<span class="fc" id="L287"> this.nullString =
csvFormat.nullString;</span>
+<span class="fc" id="L281"> private Builder(final CSVFormat csvFormat)
{</span>
+<span class="fc" id="L282"> this.allowMissingColumnNames =
csvFormat.allowMissingColumnNames;</span>
+<span class="fc" id="L283"> this.autoFlush =
csvFormat.autoFlush;</span>
+<span class="fc" id="L284"> this.commentMarker =
csvFormat.commentMarker;</span>
+<span class="fc" id="L285"> this.delimiter =
csvFormat.delimiter;</span>
+<span class="fc" id="L286"> this.duplicateHeaderMode =
csvFormat.duplicateHeaderMode;</span>
+<span class="fc" id="L287"> this.escapeCharacter =
csvFormat.escapeCharacter;</span>
<span class="fc" id="L288"> this.headerComments =
csvFormat.headerComments;</span>
<span class="fc" id="L289"> this.headers = csvFormat.headers;</span>
-<span class="fc" id="L290"> this.skipHeaderRecord =
csvFormat.skipHeaderRecord;</span>
+<span class="fc" id="L290"> this.ignoreEmptyLines =
csvFormat.ignoreEmptyLines;</span>
<span class="fc" id="L291"> this.ignoreHeaderCase =
csvFormat.ignoreHeaderCase;</span>
-<span class="fc" id="L292"> this.lenientEof =
csvFormat.lenientEof;</span>
-<span class="fc" id="L293"> this.trailingData =
csvFormat.trailingData;</span>
-<span class="fc" id="L294"> this.trailingDelimiter =
csvFormat.trailingDelimiter;</span>
-<span class="fc" id="L295"> this.trim = csvFormat.trim;</span>
-<span class="fc" id="L296"> this.autoFlush =
csvFormat.autoFlush;</span>
-<span class="fc" id="L297"> this.quotedNullString =
csvFormat.quotedNullString;</span>
-<span class="fc" id="L298"> this.duplicateHeaderMode =
csvFormat.duplicateHeaderMode;</span>
-<span class="fc" id="L299"> }</span>
+<span class="fc" id="L292"> this.ignoreSurroundingSpaces =
csvFormat.ignoreSurroundingSpaces;</span>
+<span class="fc" id="L293"> this.lenientEof =
csvFormat.lenientEof;</span>
+<span class="fc" id="L294"> this.maxRows = csvFormat.maxRows;</span>
+<span class="fc" id="L295"> this.nullString =
csvFormat.nullString;</span>
+<span class="fc" id="L296"> this.quoteCharacter =
csvFormat.quoteCharacter;</span>
+<span class="fc" id="L297"> this.quoteMode =
csvFormat.quoteMode;</span>
+<span class="fc" id="L298"> this.quotedNullString =
csvFormat.quotedNullString;</span>
+<span class="fc" id="L299"> this.recordSeparator =
csvFormat.recordSeparator;</span>
+<span class="fc" id="L300"> this.skipHeaderRecord =
csvFormat.skipHeaderRecord;</span>
+<span class="fc" id="L301"> this.trailingData =
csvFormat.trailingData;</span>
+<span class="fc" id="L302"> this.trailingDelimiter =
csvFormat.trailingDelimiter;</span>
+<span class="fc" id="L303"> this.trim = csvFormat.trim;</span>
+<span class="fc" id="L304"> }</span>
/**
* Builds a new CSVFormat instance.
@@ -306,7 +311,7 @@ public final class CSVFormat implements
*/
@Deprecated
public CSVFormat build() {
-<span class="fc" id="L309"> return get();</span>
+<span class="fc" id="L314"> return get();</span>
}
/**
@@ -317,7 +322,7 @@ public final class CSVFormat implements
*/
@Override
public CSVFormat get() {
-<span class="fc" id="L320"> return new CSVFormat(this);</span>
+<span class="fc" id="L325"> return new CSVFormat(this);</span>
}
/**
@@ -329,8 +334,8 @@ public final class CSVFormat implements
*/
@Deprecated
public Builder setAllowDuplicateHeaderNames(final boolean
allowDuplicateHeaderNames) {
-<span class="fc bfc" id="L332" title="All 2 branches covered.">
setDuplicateHeaderMode(allowDuplicateHeaderNames ?
DuplicateHeaderMode.ALLOW_ALL : DuplicateHeaderMode.ALLOW_EMPTY);</span>
-<span class="fc" id="L333"> return this;</span>
+<span class="fc bfc" id="L337" title="All 2 branches covered.">
setDuplicateHeaderMode(allowDuplicateHeaderNames ?
DuplicateHeaderMode.ALLOW_ALL : DuplicateHeaderMode.ALLOW_EMPTY);</span>
+<span class="fc" id="L338"> return this;</span>
}
/**
@@ -342,8 +347,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setAllowMissingColumnNames(final boolean
allowMissingColumnNames) {
-<span class="fc" id="L345"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
-<span class="fc" id="L346"> return this;</span>
+<span class="fc" id="L350"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
+<span class="fc" id="L351"> return this;</span>
}
/**
@@ -353,8 +358,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setAutoFlush(final boolean autoFlush) {
-<span class="fc" id="L356"> this.autoFlush = autoFlush;</span>
-<span class="fc" id="L357"> return this;</span>
+<span class="fc" id="L361"> this.autoFlush = autoFlush;</span>
+<span class="fc" id="L362"> return this;</span>
}
/**
@@ -392,8 +397,8 @@ public final class CSVFormat implements
* @throws IllegalArgumentException thrown if the specified character
is a line break
*/
public Builder setCommentMarker(final char commentMarker) {
-<span class="fc" id="L395">
setCommentMarker(Character.valueOf(commentMarker));</span>
-<span class="fc" id="L396"> return this;</span>
+<span class="fc" id="L400">
setCommentMarker(Character.valueOf(commentMarker));</span>
+<span class="fc" id="L401"> return this;</span>
}
/**
@@ -431,11 +436,11 @@ public final class CSVFormat implements
* @throws IllegalArgumentException thrown if the specified character
is a line break
*/
public Builder setCommentMarker(final Character commentMarker) {
-<span class="fc bfc" id="L434" title="All 2 branches covered."> if
(isLineBreak(commentMarker)) {</span>
-<span class="fc" id="L435"> throw new
IllegalArgumentException("The comment start marker character cannot be a
line break");</span>
+<span class="fc bfc" id="L439" title="All 2 branches covered."> if
(isLineBreak(commentMarker)) {</span>
+<span class="fc" id="L440"> throw new
IllegalArgumentException("The comment start marker character cannot be a
line break");</span>
}
-<span class="fc" id="L437"> this.commentMarker =
commentMarker;</span>
-<span class="fc" id="L438"> return this;</span>
+<span class="fc" id="L442"> this.commentMarker =
commentMarker;</span>
+<span class="fc" id="L443"> return this;</span>
}
/**
@@ -445,7 +450,7 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setDelimiter(final char delimiter) {
-<span class="fc" id="L448"> return
setDelimiter(String.valueOf(delimiter));</span>
+<span class="fc" id="L453"> return
setDelimiter(String.valueOf(delimiter));</span>
}
/**
@@ -455,14 +460,14 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setDelimiter(final String delimiter) {
-<span class="fc bfc" id="L458" title="All 2 branches covered."> if
(containsLineBreak(delimiter)) {</span>
-<span class="fc" id="L459"> throw new
IllegalArgumentException("The delimiter cannot be a line
break");</span>
+<span class="fc bfc" id="L463" title="All 2 branches covered."> if
(containsLineBreak(delimiter)) {</span>
+<span class="fc" id="L464"> throw new
IllegalArgumentException("The delimiter cannot be a line
break");</span>
}
-<span class="fc bfc" id="L461" title="All 2 branches covered."> if
(delimiter.isEmpty()) {</span>
-<span class="fc" id="L462"> throw new
IllegalArgumentException("The delimiter cannot be empty");</span>
+<span class="fc bfc" id="L466" title="All 2 branches covered."> if
(delimiter.isEmpty()) {</span>
+<span class="fc" id="L467"> throw new
IllegalArgumentException("The delimiter cannot be empty");</span>
}
-<span class="fc" id="L464"> this.delimiter = delimiter;</span>
-<span class="fc" id="L465"> return this;</span>
+<span class="fc" id="L469"> this.delimiter = delimiter;</span>
+<span class="fc" id="L470"> return this;</span>
}
/**
@@ -473,8 +478,8 @@ public final class CSVFormat implements
* @since 1.10.0
*/
public Builder setDuplicateHeaderMode(final DuplicateHeaderMode
duplicateHeaderMode) {
-<span class="fc" id="L476"> this.duplicateHeaderMode =
Objects.requireNonNull(duplicateHeaderMode,
"duplicateHeaderMode");</span>
-<span class="fc" id="L477"> return this;</span>
+<span class="fc" id="L481"> this.duplicateHeaderMode =
Objects.requireNonNull(duplicateHeaderMode,
"duplicateHeaderMode");</span>
+<span class="fc" id="L482"> return this;</span>
}
/**
@@ -485,8 +490,8 @@ public final class CSVFormat implements
* @throws IllegalArgumentException thrown if the specified character
is a line break
*/
public Builder setEscape(final char escapeCharacter) {
-<span class="fc" id="L488">
setEscape(Character.valueOf(escapeCharacter));</span>
-<span class="fc" id="L489"> return this;</span>
+<span class="fc" id="L493">
setEscape(Character.valueOf(escapeCharacter));</span>
+<span class="fc" id="L494"> return this;</span>
}
/**
@@ -497,11 +502,11 @@ public final class CSVFormat implements
* @throws IllegalArgumentException thrown if the specified character
is a line break
*/
public Builder setEscape(final Character escapeCharacter) {
-<span class="fc bfc" id="L500" title="All 2 branches covered."> if
(isLineBreak(escapeCharacter)) {</span>
-<span class="fc" id="L501"> throw new
IllegalArgumentException("The escape character cannot be a line
break");</span>
+<span class="fc bfc" id="L505" title="All 2 branches covered."> if
(isLineBreak(escapeCharacter)) {</span>
+<span class="fc" id="L506"> throw new
IllegalArgumentException("The escape character cannot be a line
break");</span>
}
-<span class="fc" id="L503"> this.escapeCharacter =
escapeCharacter;</span>
-<span class="fc" id="L504"> return this;</span>
+<span class="fc" id="L508"> this.escapeCharacter =
escapeCharacter;</span>
+<span class="fc" id="L509"> return this;</span>
}
/**
@@ -526,13 +531,13 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setHeader(final Class<? extends Enum<?>>
headerEnum) {
-<span class="fc" id="L529"> String[] header = null;</span>
-<span class="fc bfc" id="L530" title="All 2 branches covered."> if
(headerEnum != null) {</span>
-<span class="fc" id="L531"> final Enum<?>[] enumValues =
headerEnum.getEnumConstants();</span>
-<span class="fc" id="L532"> header = new
String[enumValues.length];</span>
-<span class="fc" id="L533"> Arrays.setAll(header, i ->
enumValues[i].name());</span>
+<span class="fc" id="L534"> String[] header = null;</span>
+<span class="fc bfc" id="L535" title="All 2 branches covered."> if
(headerEnum != null) {</span>
+<span class="fc" id="L536"> final Enum<?>[] enumValues =
headerEnum.getEnumConstants();</span>
+<span class="fc" id="L537"> header = new
String[enumValues.length];</span>
+<span class="fc" id="L538"> Arrays.setAll(header, i ->
enumValues[i].name());</span>
}
-<span class="fc" id="L535"> return setHeader(header);</span>
+<span class="fc" id="L540"> return setHeader(header);</span>
}
/**
@@ -556,7 +561,7 @@ public final class CSVFormat implements
* @throws SQLException SQLException if a database access error occurs
or this method is called on a closed result set.
*/
public Builder setHeader(final ResultSet resultSet) throws
SQLException {
-<span class="fc bfc" id="L559" title="All 2 branches covered.">
return setHeader(resultSet != null ? resultSet.getMetaData() : null);</span>
+<span class="fc bfc" id="L564" title="All 2 branches covered.">
return setHeader(resultSet != null ? resultSet.getMetaData() : null);</span>
}
/**
@@ -580,15 +585,15 @@ public final class CSVFormat implements
* @throws SQLException SQLException if a database access error occurs
or this method is called on a closed result set.
*/
public Builder setHeader(final ResultSetMetaData resultSetMetaData)
throws SQLException {
-<span class="fc" id="L583"> String[] labels = null;</span>
-<span class="fc bfc" id="L584" title="All 2 branches covered."> if
(resultSetMetaData != null) {</span>
-<span class="fc" id="L585"> final int columnCount =
resultSetMetaData.getColumnCount();</span>
-<span class="fc" id="L586"> labels = new
String[columnCount];</span>
-<span class="fc bfc" id="L587" title="All 2 branches covered.">
for (int i = 0; i < columnCount; i++) {</span>
-<span class="fc" id="L588"> labels[i] =
resultSetMetaData.getColumnLabel(i + 1);</span>
+<span class="fc" id="L588"> String[] labels = null;</span>
+<span class="fc bfc" id="L589" title="All 2 branches covered."> if
(resultSetMetaData != null) {</span>
+<span class="fc" id="L590"> final int columnCount =
resultSetMetaData.getColumnCount();</span>
+<span class="fc" id="L591"> labels = new
String[columnCount];</span>
+<span class="fc bfc" id="L592" title="All 2 branches covered.">
for (int i = 0; i < columnCount; i++) {</span>
+<span class="fc" id="L593"> labels[i] =
resultSetMetaData.getColumnLabel(i + 1);</span>
}
}
-<span class="fc" id="L591"> return setHeader(labels);</span>
+<span class="fc" id="L596"> return setHeader(labels);</span>
}
/**
@@ -606,13 +611,15 @@ public final class CSVFormat implements
* <p>
* The header is also used by the {@link CSVPrinter}.
* </p>
- *
+ * <p>
+ * This method keeps a copy of the input array.
+ * </p>
* @param header the header, {@code null} if disabled, empty if parsed
automatically, user-specified otherwise.
* @return This instance.
*/
public Builder setHeader(final String... header) {
-<span class="fc" id="L614"> this.headers =
CSVFormat.clone(header);</span>
-<span class="fc" id="L615"> return this;</span>
+<span class="fc" id="L621"> this.headers =
CSVFormat.clone(header);</span>
+<span class="fc" id="L622"> return this;</span>
}
/**
@@ -644,13 +651,16 @@ public final class CSVFormat implements
* # Generated by Apache Commons CSV.
* # 1970-01-01T00:00:00Z
* </pre>
+ * <p>
+ * This method keeps a copy of the input array.
+ * </p>
*
* @param headerComments the headerComments which will be printed by
the Printer before the CSV data.
* @return This instance.
*/
public Builder setHeaderComments(final Object... headerComments) {
-<span class="fc" id="L652"> this.headerComments =
CSVFormat.clone(toStringArray(headerComments));</span>
-<span class="fc" id="L653"> return this;</span>
+<span class="fc" id="L662"> this.headerComments =
CSVFormat.clone(toStringArray(headerComments));</span>
+<span class="fc" id="L663"> return this;</span>
}
/**
@@ -682,13 +692,15 @@ public final class CSVFormat implements
* # Generated by Apache Commons CSV.
* # 1970-01-01T00:00:00Z
* </pre>
- *
+ * <p>
+ * This method keeps a copy of the input array.
+ * </p>
* @param headerComments the headerComments which will be printed by
the Printer before the CSV data.
* @return This instance.
*/
public Builder setHeaderComments(final String... headerComments) {
-<span class="fc" id="L690"> this.headerComments =
CSVFormat.clone(headerComments);</span>
-<span class="fc" id="L691"> return this;</span>
+<span class="fc" id="L702"> this.headerComments =
CSVFormat.clone(headerComments);</span>
+<span class="fc" id="L703"> return this;</span>
}
/**
@@ -700,8 +712,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreEmptyLines(final boolean ignoreEmptyLines) {
-<span class="fc" id="L703"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
-<span class="fc" id="L704"> return this;</span>
+<span class="fc" id="L715"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
+<span class="fc" id="L716"> return this;</span>
}
/**
@@ -711,8 +723,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreHeaderCase(final boolean ignoreHeaderCase) {
-<span class="fc" id="L714"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
-<span class="fc" id="L715"> return this;</span>
+<span class="fc" id="L726"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
+<span class="fc" id="L727"> return this;</span>
}
/**
@@ -722,8 +734,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreSurroundingSpaces(final boolean
ignoreSurroundingSpaces) {
-<span class="fc" id="L725"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
-<span class="fc" id="L726"> return this;</span>
+<span class="fc" id="L737"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
+<span class="fc" id="L738"> return this;</span>
}
/**
@@ -734,8 +746,23 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public Builder setLenientEof(final boolean lenientEof) {
-<span class="fc" id="L737"> this.lenientEof = lenientEof;</span>
-<span class="fc" id="L738"> return this;</span>
+<span class="fc" id="L749"> this.lenientEof = lenientEof;</span>
+<span class="fc" id="L750"> return this;</span>
+ }
+
+ /**
+ * Sets the maximum number of rows to process, excluding the header
row.
+ * <p>
+ * Values less than or equal to 0 mean no limit.
+ * </p>
+ *
+ * @param maxRows the maximum number of rows to process, excluding the
header row.
+ * @return This instance.
+ * @since 1.14.0
+ */
+ public Builder setMaxRows(final long maxRows) {
+<span class="fc" id="L764"> this.maxRows = maxRows;</span>
+<span class="fc" id="L765"> return this;</span>
}
/**
@@ -750,9 +777,9 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setNullString(final String nullString) {
-<span class="fc" id="L753"> this.nullString = nullString;</span>
-<span class="fc" id="L754"> this.quotedNullString = quoteCharacter
+ nullString + quoteCharacter;</span>
-<span class="fc" id="L755"> return this;</span>
+<span class="fc" id="L780"> this.nullString = nullString;</span>
+<span class="fc" id="L781"> this.quotedNullString = quoteCharacter
+ nullString + quoteCharacter;</span>
+<span class="fc" id="L782"> return this;</span>
}
/**
@@ -762,8 +789,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuote(final char quoteCharacter) {
-<span class="fc" id="L765">
setQuote(Character.valueOf(quoteCharacter));</span>
-<span class="fc" id="L766"> return this;</span>
+<span class="fc" id="L792">
setQuote(Character.valueOf(quoteCharacter));</span>
+<span class="fc" id="L793"> return this;</span>
}
/**
@@ -773,11 +800,11 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuote(final Character quoteCharacter) {
-<span class="fc bfc" id="L776" title="All 2 branches covered."> if
(isLineBreak(quoteCharacter)) {</span>
-<span class="fc" id="L777"> throw new
IllegalArgumentException("The quoteCharacter cannot be a line
break");</span>
+<span class="fc bfc" id="L803" title="All 2 branches covered."> if
(isLineBreak(quoteCharacter)) {</span>
+<span class="fc" id="L804"> throw new
IllegalArgumentException("The quoteCharacter cannot be a line
break");</span>
}
-<span class="fc" id="L779"> this.quoteCharacter =
quoteCharacter;</span>
-<span class="fc" id="L780"> return this;</span>
+<span class="fc" id="L806"> this.quoteCharacter =
quoteCharacter;</span>
+<span class="fc" id="L807"> return this;</span>
}
/**
@@ -787,8 +814,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuoteMode(final QuoteMode quoteMode) {
-<span class="fc" id="L790"> this.quoteMode = quoteMode;</span>
-<span class="fc" id="L791"> return this;</span>
+<span class="fc" id="L817"> this.quoteMode = quoteMode;</span>
+<span class="fc" id="L818"> return this;</span>
}
/**
@@ -803,8 +830,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setRecordSeparator(final char recordSeparator) {
-<span class="fc" id="L806"> this.recordSeparator =
String.valueOf(recordSeparator);</span>
-<span class="fc" id="L807"> return this;</span>
+<span class="fc" id="L833"> this.recordSeparator =
String.valueOf(recordSeparator);</span>
+<span class="fc" id="L834"> return this;</span>
}
/**
@@ -819,8 +846,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setRecordSeparator(final String recordSeparator) {
-<span class="fc" id="L822"> this.recordSeparator =
recordSeparator;</span>
-<span class="fc" id="L823"> return this;</span>
+<span class="fc" id="L849"> this.recordSeparator =
recordSeparator;</span>
+<span class="fc" id="L850"> return this;</span>
}
/**
@@ -830,8 +857,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setSkipHeaderRecord(final boolean skipHeaderRecord) {
-<span class="fc" id="L833"> this.skipHeaderRecord =
skipHeaderRecord;</span>
-<span class="fc" id="L834"> return this;</span>
+<span class="fc" id="L860"> this.skipHeaderRecord =
skipHeaderRecord;</span>
+<span class="fc" id="L861"> return this;</span>
}
/**
@@ -842,8 +869,8 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public Builder setTrailingData(final boolean trailingData) {
-<span class="fc" id="L845"> this.trailingData = trailingData;</span>
-<span class="fc" id="L846"> return this;</span>
+<span class="fc" id="L872"> this.trailingData = trailingData;</span>
+<span class="fc" id="L873"> return this;</span>
}
/**
@@ -853,10 +880,11 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setTrailingDelimiter(final boolean trailingDelimiter) {
-<span class="fc" id="L856"> this.trailingDelimiter =
trailingDelimiter;</span>
-<span class="fc" id="L857"> return this;</span>
+<span class="fc" id="L883"> this.trailingDelimiter =
trailingDelimiter;</span>
+<span class="fc" id="L884"> return this;</span>
}
+
/**
* Sets whether to trim leading and trailing blanks.
*
@@ -864,8 +892,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setTrim(final boolean trim) {
-<span class="fc" id="L867"> this.trim = trim;</span>
-<span class="fc" id="L868"> return this;</span>
+<span class="fc" id="L895"> this.trim = trim;</span>
+<span class="fc" id="L896"> return this;</span>
}
}
@@ -874,21 +902,21 @@ public final class CSVFormat implements
*
* @since 1.2
*/
-<span class="fc" id="L877"> public enum Predefined {</span>
+<span class="fc" id="L905"> public enum Predefined {</span>
/**
* The DEFAULT predefined format.
*
* @see CSVFormat#DEFAULT
*/
-<span class="fc" id="L884"> Default(DEFAULT),</span>
+<span class="fc" id="L912"> Default(DEFAULT),</span>
/**
* The EXCEL predefined format.
*
* @see CSVFormat#EXCEL
*/
-<span class="fc" id="L891"> Excel(EXCEL),</span>
+<span class="fc" id="L919"> Excel(EXCEL),</span>
/**
* The INFORMIX_UNLOAD predefined format.
@@ -896,7 +924,7 @@ public final class CSVFormat implements
* @see CSVFormat#INFORMIX_UNLOAD
* @since 1.3
*/
-<span class="fc" id="L899"> InformixUnload(INFORMIX_UNLOAD),</span>
+<span class="fc" id="L927"> InformixUnload(INFORMIX_UNLOAD),</span>
/**
* The INFORMIX_UNLOAD_CSV predefined format.
@@ -904,7 +932,7 @@ public final class CSVFormat implements
* @see CSVFormat#INFORMIX_UNLOAD_CSV
* @since 1.3
*/
-<span class="fc" id="L907">
InformixUnloadCsv(INFORMIX_UNLOAD_CSV),</span>
+<span class="fc" id="L935">
InformixUnloadCsv(INFORMIX_UNLOAD_CSV),</span>
/**
* The MONGODB_CSV predefined format.
@@ -912,7 +940,7 @@ public final class CSVFormat implements
* @see CSVFormat#MONGODB_CSV
* @since 1.7
*/
-<span class="fc" id="L915"> MongoDBCsv(MONGODB_CSV),</span>
+<span class="fc" id="L943"> MongoDBCsv(MONGODB_CSV),</span>
/**
* The MONGODB_TSV predefined format.
@@ -920,21 +948,21 @@ public final class CSVFormat implements
* @see CSVFormat#MONGODB_TSV
* @since 1.7
*/
-<span class="fc" id="L923"> MongoDBTsv(MONGODB_TSV),</span>
+<span class="fc" id="L951"> MongoDBTsv(MONGODB_TSV),</span>
/**
* The MYSQL predefined format.
*
* @see CSVFormat#MYSQL
*/
-<span class="fc" id="L930"> MySQL(MYSQL),</span>
+<span class="fc" id="L958"> MySQL(MYSQL),</span>
/**
* The ORACLE predefined format.
*
* @see CSVFormat#ORACLE
*/
-<span class="fc" id="L937"> Oracle(ORACLE),</span>
+<span class="fc" id="L965"> Oracle(ORACLE),</span>
/**
* The POSTGRESQL_CSV predefined format.
@@ -942,34 +970,34 @@ public final class CSVFormat implements
* @see CSVFormat#POSTGRESQL_CSV
* @since 1.5
*/
-<span class="fc" id="L945"> PostgreSQLCsv(POSTGRESQL_CSV),</span>
+<span class="fc" id="L973"> PostgreSQLCsv(POSTGRESQL_CSV),</span>
/**
* The POSTGRESQL_TEXT predefined format.
*
* @see CSVFormat#POSTGRESQL_TEXT
*/
-<span class="fc" id="L952"> PostgreSQLText(POSTGRESQL_TEXT),</span>
+<span class="fc" id="L980"> PostgreSQLText(POSTGRESQL_TEXT),</span>
/**
* The RFC4180 predefined format.
*
* @see CSVFormat#RFC4180
*/
-<span class="fc" id="L959"> RFC4180(CSVFormat.RFC4180),</span>
+<span class="fc" id="L987"> RFC4180(CSVFormat.RFC4180),</span>
/**
* The TDF predefined format.
*
* @see CSVFormat#TDF
*/
-<span class="fc" id="L966"> TDF(CSVFormat.TDF);</span>
+<span class="fc" id="L994"> TDF(CSVFormat.TDF);</span>
private final CSVFormat format;
-<span class="fc" id="L970"> Predefined(final CSVFormat format) {</span>
-<span class="fc" id="L971"> this.format = format;</span>
-<span class="fc" id="L972"> }</span>
+<span class="fc" id="L998"> Predefined(final CSVFormat format) {</span>
+<span class="fc" id="L999"> this.format = format;</span>
+<span class="fc" id="L1000"> }</span>
/**
* Gets the format.
@@ -977,7 +1005,7 @@ public final class CSVFormat implements
* @return the format.
*/
public CSVFormat getFormat() {
-<span class="fc" id="L980"> return format;</span>
+<span class="fc" id="L1008"> return format;</span>
}
}
@@ -998,18 +1026,19 @@ public final class CSVFormat implements
* @see Predefined#Default
* @see DuplicateHeaderMode#ALLOW_ALL
*/
-<span class="fc" id="L1001"> public static final CSVFormat DEFAULT = new
CSVFormat(Builder.create());</span>
+<span class="fc" id="L1029"> public static final CSVFormat DEFAULT = new
CSVFormat(Builder.create());</span>
/**
- * Excel file format (using a comma as the value delimiter). Note that the
actual value delimiter used by Excel is locale-dependent, it might be necessary
- * to customize this format to accommodate your regional settings.
+ * <a
href="https://support.microsoft.com/en-us/office/import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba">Microsoft
Excel</a> file
+ * format (using a comma as the value delimiter). Note that the actual
value delimiter used by Excel is locale-dependent, it might be necessary to
customize
+ * this format to accommodate your regional settings.
*
* <p>
* For example for parsing or generating a CSV file on a French system the
following format will be used:
* </p>
*
* <pre>
- * CSVFormat fmt = CSVFormat.EXCEL.builder().setDelimiter(';').get();
+ * CSVFormat format = CSVFormat.EXCEL.builder().setDelimiter(';').get();
* </pre>
*
* <p>
@@ -1032,18 +1061,21 @@ public final class CSVFormat implements
*
* @see Predefined#Excel
* @see DuplicateHeaderMode#ALLOW_ALL
+ * @see <a
href="https://support.microsoft.com/en-us/office/import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba">Microsoft
Excel
+ * </a>
*/
// @formatter:off
-<span class="fc" id="L1037"> public static final CSVFormat EXCEL =
DEFAULT.builder()</span>
-<span class="fc" id="L1038"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1039">
.setAllowMissingColumnNames(true)</span>
-<span class="fc" id="L1040"> .setTrailingData(true)</span>
-<span class="fc" id="L1041"> .setLenientEof(true)</span>
-<span class="fc" id="L1042"> .get();</span>
+<span class="fc" id="L1068"> public static final CSVFormat EXCEL =
DEFAULT.builder()</span>
+<span class="fc" id="L1069"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1070">
.setAllowMissingColumnNames(true)</span>
+<span class="fc" id="L1071"> .setTrailingData(true)</span>
+<span class="fc" id="L1072"> .setLenientEof(true)</span>
+<span class="fc" id="L1073"> .get();</span>
// @formatter:on
/**
- * Default Informix CSV UNLOAD format used by the {@code UNLOAD TO
file_name} operation.
+ * Default <a
href="https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-unload-statement">Informix
CSV UNLOAD</a>
+ * format used by the {@code UNLOAD TO file_name} operation.
*
* <p>
* This is a comma-delimited format with an LF character as the line
separator. Values are not quoted and special characters are escaped with {@code
'\'}.
@@ -1061,21 +1093,21 @@ public final class CSVFormat implements
* </ul>
*
* @see Predefined#MySQL
- * @see <a href=
"http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fgl_InOutSql_UNLOAD.htm">
- *
http://www.ibm.com/support/knowledgecenter/SSBJG3_2.5.0/com.ibm.gen_busug.doc/c_fgl_InOutSql_UNLOAD.htm</a>
+ * @see <a
href="https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-unload-statement">Informix
CSV UNLOAD</a>
* @since 1.3
*/
// @formatter:off
-<span class="fc" id="L1069"> public static final CSVFormat INFORMIX_UNLOAD
= DEFAULT.builder()</span>
-<span class="fc" id="L1070"> .setDelimiter(Constants.PIPE)</span>
-<span class="fc" id="L1071"> .setEscape(Constants.BACKSLASH)</span>
-<span class="fc" id="L1072">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1073">
.setRecordSeparator(Constants.LF)</span>
-<span class="fc" id="L1074"> .get();</span>
+<span class="fc" id="L1100"> public static final CSVFormat INFORMIX_UNLOAD
= DEFAULT.builder()</span>
+<span class="fc" id="L1101"> .setDelimiter(Constants.PIPE)</span>
+<span class="fc" id="L1102"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1103">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1104">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1105"> .get();</span>
// @formatter:on
/**
- * Default Informix CSV UNLOAD format used by the {@code UNLOAD TO
file_name} operation (escaping is disabled.)
+ * Default <a
href="https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-unload-statement">Informix
CSV UNLOAD</a>
+ * format used by the {@code UNLOAD TO file_name} operation (escaping is
disabled.)
*
* <p>
* This is a comma-delimited format with an LF character as the line
separator. Values are not quoted and special characters are escaped with {@code
'\'}.
@@ -1097,11 +1129,11 @@ public final class CSVFormat implements
* @since 1.3
*/
// @formatter:off
-<span class="fc" id="L1100"> public static final CSVFormat
INFORMIX_UNLOAD_CSV = DEFAULT.builder()</span>
-<span class="fc" id="L1101"> .setDelimiter(Constants.COMMA)</span>
-<span class="fc" id="L1102">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1103">
.setRecordSeparator(Constants.LF)</span>
-<span class="fc" id="L1104"> .get();</span>
+<span class="fc" id="L1132"> public static final CSVFormat
INFORMIX_UNLOAD_CSV = DEFAULT.builder()</span>
+<span class="fc" id="L1133"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1134">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1135">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1136"> .get();</span>
// @formatter:on
/**
@@ -1127,7 +1159,7 @@ public final class CSVFormat implements
* <li>{@link Builder#setDelimiter(char) setDelimiter}{@code
(',')}</li>
* <li>{@link Builder#setEscape(char) setEscape}{@code
('"')}</li>
* <li>{@link Builder#setQuote(char) setQuote}{@code
('"')}</li>
- * <li>{@link Builder#setQuoteMode(QuoteMode) setQuoteMode}{@code
(QuoteMode.ALL_NON_NULL)}</li>
+ * <li>{@link Builder#setQuoteMode(QuoteMode) setQuoteMode}{@code
(QuoteMode.MINIMAL)}</li>
* </ul>
*
* @see Predefined#MongoDBCsv
@@ -1136,12 +1168,12 @@ public final class CSVFormat implements
* @since 1.7
*/
// @formatter:off
-<span class="fc" id="L1139"> public static final CSVFormat MONGODB_CSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1140"> .setDelimiter(Constants.COMMA)</span>
-<span class="fc" id="L1141">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1142">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1143"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1144"> .get();</span>
+<span class="fc" id="L1171"> public static final CSVFormat MONGODB_CSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1172"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1173">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1174">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1175"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1176"> .get();</span>
// @formatter:off
/**
@@ -1162,8 +1194,8 @@ public final class CSVFormat implements
* <li>{@link Builder#setDelimiter(char) setDelimiter}{@code
('\t')}</li>
* <li>{@link Builder#setEscape(char) setEscape}{@code
('"')}</li>
* <li>{@link Builder#setQuote(char) setQuote}{@code
('"')}</li>
- * <li>{@link Builder#setQuoteMode(QuoteMode) setQuoteMode}{@code
(QuoteMode.ALL_NON_NULL)}</li>
- * <li>{@code setSkipHeaderRecord(false)}</li>
+ * <li>{@link Builder#setQuoteMode(QuoteMode) setQuoteMode}{@code
(QuoteMode.MINIMAL)}</li>
+ * <li>{@link Builder#setSkipHeaderRecord(boolean)
setSkipHeaderRecord}{@code (false)}</li>
* </ul>
*
* @see Predefined#MongoDBCsv
@@ -1173,17 +1205,18 @@ public final class CSVFormat implements
* @since 1.7
*/
// @formatter:off
-<span class="fc" id="L1176"> public static final CSVFormat MONGODB_TSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1177"> .setDelimiter(Constants.TAB)</span>
-<span class="fc" id="L1178">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1179">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1180"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1181"> .setSkipHeaderRecord(false)</span>
-<span class="fc" id="L1182"> .get();</span>
+<span class="fc" id="L1208"> public static final CSVFormat MONGODB_TSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1209"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1210">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1211">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1212"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1213"> .setSkipHeaderRecord(false)</span>
+<span class="fc" id="L1214"> .get();</span>
// @formatter:off
/**
- * Default MySQL format used by the {@code SELECT INTO OUTFILE} and {@code
LOAD DATA INFILE} operations.
+ * Default <a
href="https://dev.mysql.com/doc/refman/8.0/en/mysqldump-delimited-text.html">MySQL</a>
+ * format used by the {@code SELECT INTO OUTFILE} and {@code LOAD DATA
INFILE} operations.
*
* <p>
* This is a tab-delimited format with an LF character as the line
separator. Values are not quoted and special
@@ -1205,23 +1238,24 @@ public final class CSVFormat implements
*
* @see Predefined#MySQL
* @see QuoteMode#ALL_NON_NULL
- * @see <a
href="https://dev.mysql.com/doc/refman/5.1/en/load-data.html">
https://dev.mysql.com/doc/refman/5.1/en/load
- * -data.html</a>
+ * @see <a
href="https://dev.mysql.com/doc/refman/8.0/en/mysqldump-delimited-text.html">MySQL</a>
*/
// @formatter:off
-<span class="fc" id="L1212"> public static final CSVFormat MYSQL =
DEFAULT.builder()</span>
-<span class="fc" id="L1213"> .setDelimiter(Constants.TAB)</span>
-<span class="fc" id="L1214"> .setEscape(Constants.BACKSLASH)</span>
-<span class="fc" id="L1215"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1216"> .setQuote(null)</span>
-<span class="fc" id="L1217">
.setRecordSeparator(Constants.LF)</span>
-<span class="fc" id="L1218">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1219">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1220"> .get();</span>
+<span class="fc" id="L1244"> public static final CSVFormat MYSQL =
DEFAULT.builder()</span>
+<span class="fc" id="L1245"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1246"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1247"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1248"> .setQuote(null)</span>
+<span class="fc" id="L1249">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1250">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1251">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1252"> .get();</span>
// @formatter:off
/**
- * Default Oracle format used by the SQL*Loader utility.
+ * Default
+ * <a
href="https://docs.oracle.com/en/database/oracle/oracle-database/23/sutil/oracle-sql-loader-control-file-contents.html#GUID-D1762699-8154-40F6-90DE-EFB8EB6A9AB0">Oracle</a>
+ * format used by the SQL*Loader utility.
*
* <p>
* This is a comma-delimited format with the system line separator
character as the record separator. Values are
@@ -1245,24 +1279,24 @@ public final class CSVFormat implements
*
* @see Predefined#Oracle
* @see QuoteMode#MINIMAL
- * @see <a href="https://s.apache.org/CGXG">Oracle CSV
Format Specification</a>
+ * @see <a
href="https://docs.oracle.com/en/database/oracle/oracle-database/23/sutil/oracle-sql-loader-control-file-contents.html#GUID-D1762699-8154-40F6-90DE-EFB8EB6A9AB0">Oracle
CSV Format Specification</a>
* @since 1.6
*/
// @formatter:off
-<span class="fc" id="L1252"> public static final CSVFormat ORACLE =
DEFAULT.builder()</span>
-<span class="fc" id="L1253"> .setDelimiter(Constants.COMMA)</span>
-<span class="fc" id="L1254"> .setEscape(Constants.BACKSLASH)</span>
-<span class="fc" id="L1255"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1256">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1257">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1258"> .setTrim(true)</span>
-<span class="fc" id="L1259">
.setRecordSeparator(System.lineSeparator())</span>
-<span class="fc" id="L1260"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1261"> .get();</span>
+<span class="fc" id="L1286"> public static final CSVFormat ORACLE =
DEFAULT.builder()</span>
+<span class="fc" id="L1287"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1288"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1289"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1290">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1291">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1292"> .setTrim(true)</span>
+<span class="fc" id="L1293">
.setRecordSeparator(System.lineSeparator())</span>
+<span class="fc" id="L1294"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1295"> .get();</span>
// @formatter:off
/**
- * Default PostgreSQL CSV format used by the {@code COPY} operation.
+ * Default <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
CSV</a> format used by the {@code COPY} operation.
*
* <p>
* This is a comma-delimited format with an LF character as the line
separator. Values are double quoted and special
@@ -1284,24 +1318,23 @@ public final class CSVFormat implements
*
* @see Predefined#MySQL
* @see QuoteMode#ALL_NON_NULL
- * @see <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
COPY command
- * documentation</a>
+ * @see <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
CSV</a>
* @since 1.5
*/
// @formatter:off
-<span class="fc" id="L1292"> public static final CSVFormat POSTGRESQL_CSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1293"> .setDelimiter(Constants.COMMA)</span>
-<span class="fc" id="L1294"> .setEscape(null)</span>
-<span class="fc" id="L1295"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1296">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1297">
.setRecordSeparator(Constants.LF)</span>
-<span class="fc" id="L1298"> .setNullString(Constants.EMPTY)</span>
-<span class="fc" id="L1299">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1300"> .get();</span>
+<span class="fc" id="L1325"> public static final CSVFormat POSTGRESQL_CSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1326"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1327"> .setEscape(null)</span>
+<span class="fc" id="L1328"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1329">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1330">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1331"> .setNullString(Constants.EMPTY)</span>
+<span class="fc" id="L1332">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1333"> .get();</span>
// @formatter:off
/**
- * Default PostgreSQL text format used by the {@code COPY} operation.
+ * Default <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
Text</a> format used by the {@code COPY} operation.
*
* <p>
* This is a tab-delimited format with an LF character as the line
separator. Values are not quoted and special
@@ -1323,20 +1356,19 @@ public final class CSVFormat implements
*
* @see Predefined#MySQL
* @see QuoteMode#ALL_NON_NULL
- * @see <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
COPY command
- * documentation</a>
+ * @see <a
href="https://www.postgresql.org/docs/current/static/sql-copy.html">PostgreSQL
Text</a>
* @since 1.5
*/
// @formatter:off
-<span class="fc" id="L1331"> public static final CSVFormat POSTGRESQL_TEXT
= DEFAULT.builder()</span>
-<span class="fc" id="L1332"> .setDelimiter(Constants.TAB)</span>
-<span class="fc" id="L1333"> .setEscape(Constants.BACKSLASH)</span>
-<span class="fc" id="L1334"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1335"> .setQuote(null)</span>
-<span class="fc" id="L1336">
.setRecordSeparator(Constants.LF)</span>
-<span class="fc" id="L1337">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1338">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1339"> .get();</span>
+<span class="fc" id="L1363"> public static final CSVFormat POSTGRESQL_TEXT
= DEFAULT.builder()</span>
+<span class="fc" id="L1364"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1365"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1366"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1367"> .setQuote(null)</span>
+<span class="fc" id="L1368">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1369">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1370">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1371"> .get();</span>
// @formatter:off
/**
@@ -1353,13 +1385,14 @@ public final class CSVFormat implements
* </ul>
*
* @see Predefined#RFC4180
+ * @see <a href="https://tools.ietf.org/html/rfc4180">RFC
4180</a>
*/
-<span class="fc" id="L1357"> public static final CSVFormat RFC4180 =
DEFAULT.builder().setIgnoreEmptyLines(false).get();</span>
+<span class="fc" id="L1390"> public static final CSVFormat RFC4180 =
DEFAULT.builder().setIgnoreEmptyLines(false).get();</span>
private static final long serialVersionUID = 2L;
/**
- * Tab-delimited format (TDF).
+ * Tab-delimited format (<a
href="https://en.wikipedia.org/wiki/Tab-separated_values">TDF</a>).
*
* <p>
* The {@link Builder} settings are the {@link #DEFAULT}
<em>with</em>:
@@ -1370,12 +1403,13 @@ public final class CSVFormat implements
* </ul>
*
* @see Predefined#TDF
+ * @see <a
href="https://en.wikipedia.org/wiki/Tab-separated_values">TDF</a>
*/
// @formatter:off
-<span class="fc" id="L1375"> public static final CSVFormat TDF =
DEFAULT.builder()</span>
-<span class="fc" id="L1376"> .setDelimiter(Constants.TAB)</span>
-<span class="fc" id="L1377">
.setIgnoreSurroundingSpaces(true)</span>
-<span class="fc" id="L1378"> .get();</span>
+<span class="fc" id="L1409"> public static final CSVFormat TDF =
DEFAULT.builder()</span>
+<span class="fc" id="L1410"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1411">
.setIgnoreSurroundingSpaces(true)</span>
+<span class="fc" id="L1412"> .get();</span>
// @formatter:on
/**
@@ -1387,7 +1421,7 @@ public final class CSVFormat implements
*/
@SafeVarargs
static <T> T[] clone(final T... values) {
-<span class="fc bfc" id="L1390" title="All 2 branches covered."> return
values == null ? null : values.clone();</span>
+<span class="fc bfc" id="L1424" title="All 2 branches covered."> return
values == null ? null : values.clone();</span>
}
/**
@@ -1398,7 +1432,7 @@ public final class CSVFormat implements
* @return true if {@code c} contains a line break character
*/
private static boolean contains(final String source, final char searchCh) {
-<span class="fc bfc" id="L1401" title="All 2 branches covered."> return
Objects.requireNonNull(source, "source").indexOf(searchCh) >=
0;</span>
+<span class="fc bfc" id="L1435" title="All 2 branches covered."> return
Objects.requireNonNull(source, "source").indexOf(searchCh) >=
0;</span>
}
/**
@@ -1408,7 +1442,7 @@ public final class CSVFormat implements
* @return true if {@code c} contains a line break character.
*/
private static boolean containsLineBreak(final String source) {
-<span class="fc bfc" id="L1411" title="All 4 branches covered."> return
contains(source, Constants.CR) || contains(source, Constants.LF);</span>
+<span class="fc bfc" id="L1445" title="All 4 branches covered."> return
contains(source, Constants.CR) || contains(source, Constants.LF);</span>
}
/**
@@ -1417,11 +1451,11 @@ public final class CSVFormat implements
* @return a copy of the given instance or null if the input is null.
*/
static CSVFormat copy(final CSVFormat format) {
-<span class="pc bpc" id="L1420" title="1 of 2 branches missed."> return
format != null ? format.copy() : null;</span>
+<span class="fc bfc" id="L1454" title="All 2 branches covered."> return
format != null ? format.copy() : null;</span>
}
static boolean isBlank(final String value) {
-<span class="fc bfc" id="L1424" title="All 4 branches covered."> return
value == null || value.trim().isEmpty();</span>
+<span class="fc bfc" id="L1458" title="All 4 branches covered."> return
value == null || value.trim().isEmpty();</span>
}
/**
@@ -1431,7 +1465,7 @@ public final class CSVFormat implements
* @return true if {@code c} is a line break character.
*/
private static boolean isLineBreak(final char c) {
-<span class="fc bfc" id="L1434" title="All 4 branches covered."> return
c == Constants.LF || c == Constants.CR;</span>
+<span class="fc bfc" id="L1468" title="All 4 branches covered."> return
c == Constants.LF || c == Constants.CR;</span>
}
/**
@@ -1441,17 +1475,17 @@ public final class CSVFormat implements
* @return true if {@code c} is a line break character (and not null).
*/
private static boolean isLineBreak(final Character c) {
-<span class="fc bfc" id="L1444" title="All 4 branches covered."> return
c != null && isLineBreak(c.charValue()); // N.B. Explicit (un)boxing is
intentional</span>
+<span class="fc bfc" id="L1478" title="All 4 branches covered."> return
c != null && isLineBreak(c.charValue()); // Explicit (un)boxing is
intentional</span>
}
/** Same test as in as {@link String#trim()}. */
private static boolean isTrimChar(final char ch) {
-<span class="fc bfc" id="L1449" title="All 2 branches covered."> return
ch <= Constants.SP;</span>
+<span class="fc bfc" id="L1483" title="All 2 branches covered."> return
ch <= Constants.SP;</span>
}
/** Same test as in as {@link String#trim()}. */
private static boolean isTrimChar(final CharSequence charSequence, final
int pos) {
-<span class="fc" id="L1454"> return
isTrimChar(charSequence.charAt(pos));</span>
+<span class="fc" id="L1488"> return
isTrimChar(charSequence.charAt(pos));</span>
}
/**
@@ -1471,33 +1505,33 @@ public final class CSVFormat implements
* @see #TDF
*/
public static CSVFormat newFormat(final char delimiter) {
-<span class="fc" id="L1474"> return new CSVFormat(new
Builder().setDelimiter(delimiter));</span>
+<span class="fc" id="L1508"> return new CSVFormat(new
Builder().setDelimiter(delimiter));</span>
}
static String[] toStringArray(final Object[] values) {
-<span class="fc bfc" id="L1478" title="All 2 branches covered."> if
(values == null) {</span>
-<span class="fc" id="L1479"> return null;</span>
+<span class="fc bfc" id="L1512" title="All 2 branches covered."> if
(values == null) {</span>
+<span class="fc" id="L1513"> return null;</span>
}
-<span class="fc" id="L1481"> final String[] strings = new
String[values.length];</span>
-<span class="fc" id="L1482"> Arrays.setAll(strings, i ->
Objects.toString(values[i], null));</span>
-<span class="fc" id="L1483"> return strings;</span>
+<span class="fc" id="L1515"> final String[] strings = new
String[values.length];</span>
+<span class="fc" id="L1516"> Arrays.setAll(strings, i ->
Objects.toString(values[i], null));</span>
+<span class="fc" id="L1517"> return strings;</span>
}
static CharSequence trim(final CharSequence charSequence) {
-<span class="fc bfc" id="L1487" title="All 2 branches covered."> if
(charSequence instanceof String) {</span>
-<span class="fc" id="L1488"> return ((String)
charSequence).trim();</span>
+<span class="fc bfc" id="L1521" title="All 2 branches covered."> if
(charSequence instanceof String) {</span>
+<span class="fc" id="L1522"> return ((String)
charSequence).trim();</span>
}
-<span class="fc" id="L1490"> final int count =
charSequence.length();</span>
-<span class="fc" id="L1491"> int len = count;</span>
-<span class="fc" id="L1492"> int pos = 0;</span>
+<span class="fc" id="L1524"> final int count =
charSequence.length();</span>
+<span class="fc" id="L1525"> int len = count;</span>
+<span class="fc" id="L1526"> int pos = 0;</span>
-<span class="fc bfc" id="L1494" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, pos)) {</span>
-<span class="fc" id="L1495"> pos++;</span>
+<span class="fc bfc" id="L1528" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, pos)) {</span>
+<span class="fc" id="L1529"> pos++;</span>
}
-<span class="fc bfc" id="L1497" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, len - 1)) {</span>
-<span class="fc" id="L1498"> len--;</span>
+<span class="fc bfc" id="L1531" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, len - 1)) {</span>
+<span class="fc" id="L1532"> len--;</span>
}
-<span class="fc bfc" id="L1500" title="All 4 branches covered."> return
pos > 0 || len < count ? charSequence.subSequence(pos, len) :
charSequence;</span>
+<span class="fc bfc" id="L1534" title="All 4 branches covered."> return
pos > 0 || len < count ? charSequence.subSequence(pos, len) :
charSequence;</span>
}
/**
@@ -1508,7 +1542,7 @@ public final class CSVFormat implements
* @since 1.2
*/
public static CSVFormat valueOf(final String format) {
-<span class="fc" id="L1511"> return
CSVFormat.Predefined.valueOf(format).getFormat();</span>
+<span class="fc" id="L1545"> return
CSVFormat.Predefined.valueOf(format).getFormat();</span>
}
/** How duplicate headers are handled. */
@@ -1574,46 +1608,50 @@ public final class CSVFormat implements
/** Whether to trim leading and trailing blanks. */
private final boolean trim;
-<span class="fc" id="L1577"> private CSVFormat(final Builder builder)
{</span>
-<span class="fc" id="L1578"> this.delimiter = builder.delimiter;</span>
-<span class="fc" id="L1579"> this.quoteCharacter =
builder.quoteCharacter;</span>
-<span class="fc" id="L1580"> this.quoteMode = builder.quoteMode;</span>
-<span class="fc" id="L1581"> this.commentMarker =
builder.commentMarker;</span>
-<span class="fc" id="L1582"> this.escapeCharacter =
builder.escapeCharacter;</span>
-<span class="fc" id="L1583"> this.ignoreSurroundingSpaces =
builder.ignoreSurroundingSpaces;</span>
-<span class="fc" id="L1584"> this.allowMissingColumnNames =
builder.allowMissingColumnNames;</span>
-<span class="fc" id="L1585"> this.ignoreEmptyLines =
builder.ignoreEmptyLines;</span>
-<span class="fc" id="L1586"> this.recordSeparator =
builder.recordSeparator;</span>
-<span class="fc" id="L1587"> this.nullString =
builder.nullString;</span>
-<span class="fc" id="L1588"> this.headerComments =
builder.headerComments;</span>
-<span class="fc" id="L1589"> this.headers = builder.headers;</span>
-<span class="fc" id="L1590"> this.skipHeaderRecord =
builder.skipHeaderRecord;</span>
-<span class="fc" id="L1591"> this.ignoreHeaderCase =
builder.ignoreHeaderCase;</span>
-<span class="fc" id="L1592"> this.lenientEof =
builder.lenientEof;</span>
-<span class="fc" id="L1593"> this.trailingData =
builder.trailingData;</span>
-<span class="fc" id="L1594"> this.trailingDelimiter =
builder.trailingDelimiter;</span>
-<span class="fc" id="L1595"> this.trim = builder.trim;</span>
-<span class="fc" id="L1596"> this.autoFlush = builder.autoFlush;</span>
-<span class="fc" id="L1597"> this.quotedNullString =
builder.quotedNullString;</span>
-<span class="fc" id="L1598"> this.duplicateHeaderMode =
builder.duplicateHeaderMode;</span>
-<span class="fc" id="L1599"> validate();</span>
-<span class="fc" id="L1600"> }</span>
+ /** The maximum number of rows to process, excluding the header row. */
+ private final long maxRows;
+
+<span class="fc" id="L1614"> private CSVFormat(final Builder builder)
{</span>
+<span class="fc" id="L1615"> this.allowMissingColumnNames =
builder.allowMissingColumnNames;</span>
+<span class="fc" id="L1616"> this.autoFlush = builder.autoFlush;</span>
+<span class="fc" id="L1617"> this.commentMarker =
builder.commentMarker;</span>
+<span class="fc" id="L1618"> this.delimiter = builder.delimiter;</span>
+<span class="fc" id="L1619"> this.duplicateHeaderMode =
builder.duplicateHeaderMode;</span>
+<span class="fc" id="L1620"> this.escapeCharacter =
builder.escapeCharacter;</span>
+<span class="fc" id="L1621"> this.headerComments =
builder.headerComments;</span>
+<span class="fc" id="L1622"> this.headers = builder.headers;</span>
+<span class="fc" id="L1623"> this.ignoreEmptyLines =
builder.ignoreEmptyLines;</span>
+<span class="fc" id="L1624"> this.ignoreHeaderCase =
builder.ignoreHeaderCase;</span>
+<span class="fc" id="L1625"> this.ignoreSurroundingSpaces =
builder.ignoreSurroundingSpaces;</span>
+<span class="fc" id="L1626"> this.lenientEof =
builder.lenientEof;</span>
+<span class="fc" id="L1627"> this.maxRows = builder.maxRows;</span>
+<span class="fc" id="L1628"> this.nullString =
builder.nullString;</span>
+<span class="fc" id="L1629"> this.quoteCharacter =
builder.quoteCharacter;</span>
+<span class="fc" id="L1630"> this.quoteMode = builder.quoteMode;</span>
+<span class="fc" id="L1631"> this.quotedNullString =
builder.quotedNullString;</span>
+<span class="fc" id="L1632"> this.recordSeparator =
builder.recordSeparator;</span>
+<span class="fc" id="L1633"> this.skipHeaderRecord =
builder.skipHeaderRecord;</span>
+<span class="fc" id="L1634"> this.trailingData =
builder.trailingData;</span>
+<span class="fc" id="L1635"> this.trailingDelimiter =
builder.trailingDelimiter;</span>
+<span class="fc" id="L1636"> this.trim = builder.trim;</span>
+<span class="fc" id="L1637"> validate();</span>
+<span class="fc" id="L1638"> }</span>
private void append(final char c, final Appendable appendable) throws
IOException {
// try {
-<span class="fc" id="L1604"> appendable.append(c);</span>
+<span class="fc" id="L1642"> appendable.append(c);</span>
// } catch (final IOException e) {
// throw new UncheckedIOException(e);
// }
-<span class="fc" id="L1608"> }</span>
+<span class="fc" id="L1646"> }</span>
private void append(final CharSequence csq, final Appendable appendable)
throws IOException {
// try {
-<span class="fc" id="L1612"> appendable.append(csq);</span>
+<span class="fc" id="L1650"> appendable.append(csq);</span>
// } catch (final IOException e) {
// throw new UncheckedIOException(e);
// }
-<span class="fc" id="L1616"> }</span>
+<span class="fc" id="L1654"> }</span>
/**
* Creates a new Builder for this instance.
@@ -1621,7 +1659,7 @@ public final class CSVFormat implements
* @return a new Builder.
*/
public Builder builder() {
-<span class="fc" id="L1624"> return Builder.create(this);</span>
+<span class="fc" id="L1662"> return Builder.create(this);</span>
}
/**
@@ -1630,55 +1668,55 @@ public final class CSVFormat implements
* @return a copy of this instance.
*/
CSVFormat copy() {
-<span class="fc" id="L1633"> return builder().get();</span>
+<span class="fc" id="L1671"> return builder().get();</span>
}
@Override
public boolean equals(final Object obj) {
-<span class="fc bfc" id="L1638" title="All 2 branches covered."> if
(this == obj) {</span>
-<span class="fc" id="L1639"> return true;</span>
+<span class="fc bfc" id="L1676" title="All 2 branches covered."> if
(this == obj) {</span>
+<span class="fc" id="L1677"> return true;</span>
}
-<span class="fc bfc" id="L1641" title="All 2 branches covered."> if
(obj == null) {</span>
-<span class="fc" id="L1642"> return false;</span>
+<span class="fc bfc" id="L1679" title="All 2 branches covered."> if
(obj == null) {</span>
+<span class="fc" id="L1680"> return false;</span>
}
-<span class="fc bfc" id="L1644" title="All 2 branches covered."> if
(getClass() != obj.getClass()) {</span>
-<span class="fc" id="L1645"> return false;</span>
+<span class="fc bfc" id="L1682" title="All 2 branches covered."> if
(getClass() != obj.getClass()) {</span>
+<span class="fc" id="L1683"> return false;</span>
}
-<span class="fc" id="L1647"> final CSVFormat other = (CSVFormat)
obj;</span>
-<span class="fc bfc" id="L1648" title="All 4 branches covered."> return
allowMissingColumnNames == other.allowMissingColumnNames && autoFlush
== other.autoFlush &&</span>
-<span class="fc bfc" id="L1649" title="All 6 branches covered.">
Objects.equals(commentMarker, other.commentMarker) &&
Objects.equals(delimiter, other.delimiter) &&</span>
-<span class="fc bfc" id="L1650" title="All 2 branches covered.">
duplicateHeaderMode == other.duplicateHeaderMode &&
Objects.equals(escapeCharacter, other.escapeCharacter) &&</span>
-<span class="pc bpc" id="L1651" title="1 of 12 branches missed.">
Arrays.equals(headerComments, other.headerComments) &&
Arrays.equals(headers, other.headers) &&</span>
+<span class="fc" id="L1685"> final CSVFormat other = (CSVFormat)
obj;</span>
+<span class="fc bfc" id="L1686" title="All 4 branches covered."> return
allowMissingColumnNames == other.allowMissingColumnNames && autoFlush
== other.autoFlush &&</span>
+<span class="fc bfc" id="L1687" title="All 6 branches covered.">
Objects.equals(commentMarker, other.commentMarker) &&
Objects.equals(delimiter, other.delimiter) &&</span>
+<span class="fc bfc" id="L1688" title="All 2 branches covered.">
duplicateHeaderMode == other.duplicateHeaderMode &&
Objects.equals(escapeCharacter, other.escapeCharacter) &&</span>
+<span class="pc bpc" id="L1689" title="1 of 12 branches missed.">
Arrays.equals(headerComments, other.headerComments) &&
Arrays.equals(headers, other.headers) &&</span>
ignoreEmptyLines == other.ignoreEmptyLines &&
ignoreHeaderCase == other.ignoreHeaderCase &&
ignoreSurroundingSpaces == other.ignoreSurroundingSpaces
&& lenientEof == other.lenientEof &&
-<span class="fc bfc" id="L1654" title="All 6 branches covered.">
Objects.equals(nullString, other.nullString) &&
Objects.equals(quoteCharacter, other.quoteCharacter) &&</span>
-<span class="pc bpc" id="L1655" title="1 of 2 branches missed.">
quoteMode == other.quoteMode && Objects.equals(quotedNullString,
other.quotedNullString) &&</span>
-<span class="pc bpc" id="L1656" title="1 of 10 branches missed.">
Objects.equals(recordSeparator, other.recordSeparator) &&
skipHeaderRecord == other.skipHeaderRecord &&</span>
+<span class="fc bfc" id="L1692" title="All 6 branches covered.">
Objects.equals(nullString, other.nullString) &&
Objects.equals(quoteCharacter, other.quoteCharacter) &&</span>
+<span class="pc bpc" id="L1693" title="1 of 2 branches missed.">
quoteMode == other.quoteMode && Objects.equals(quotedNullString,
other.quotedNullString) &&</span>
+<span class="pc bpc" id="L1694" title="1 of 10 branches missed.">
Objects.equals(recordSeparator, other.recordSeparator) &&
skipHeaderRecord == other.skipHeaderRecord &&</span>
trailingData == other.trailingData &&
trailingDelimiter == other.trailingDelimiter && trim == other.trim;
}
private void escape(final char c, final Appendable appendable) throws
IOException {
-<span class="fc" id="L1661"> append(escapeCharacter.charValue(),
appendable); // N.B. Explicit (un)boxing is intentional</span>
-<span class="fc" id="L1662"> append(c, appendable);</span>
-<span class="fc" id="L1663"> }</span>
+<span class="fc" id="L1699"> append(escapeCharacter.charValue(),
appendable); // Explicit (un)boxing is intentional</span>
+<span class="fc" id="L1700"> append(c, appendable);</span>
+<span class="fc" id="L1701"> }</span>
/**
- * Formats the specified values.
+ * Formats the specified values as a CSV record string.
*
- * @param values the values to format
- * @return the formatted values
+ * @param values the values to format.
+ * @return the formatted values.
*/
public String format(final Object... values) {
-<span class="fc" id="L1672"> return Uncheck.get(() ->
format_(values));</span>
+<span class="fc" id="L1710"> return Uncheck.get(() ->
format_(values));</span>
}
private String format_(final Object... values) throws IOException {
-<span class="fc" id="L1676"> final StringWriter out = new
StringWriter();</span>
-<span class="fc" id="L1677"> try (CSVPrinter csvPrinter = new
CSVPrinter(out, this)) {</span>
-<span class="fc" id="L1678"> csvPrinter.printRecord(values);</span>
-<span class="fc" id="L1679"> final String res =
out.toString();</span>
-<span class="fc bfc" id="L1680" title="All 2 branches covered.">
final int len = recordSeparator != null ? res.length() -
recordSeparator.length() : res.length();</span>
-<span class="fc" id="L1681"> return res.substring(0, len);</span>
+<span class="fc" id="L1714"> final StringWriter out = new
StringWriter();</span>
+<span class="fc" id="L1715"> try (CSVPrinter csvPrinter = new
CSVPrinter(out, this)) {</span>
+<span class="fc" id="L1716"> csvPrinter.printRecord(values);</span>
+<span class="fc" id="L1717"> final String res =
out.toString();</span>
+<span class="fc bfc" id="L1718" title="All 2 branches covered.">
final int len = recordSeparator != null ? res.length() -
recordSeparator.length() : res.length();</span>
+<span class="fc" id="L1719"> return res.substring(0, len);</span>
}
}
@@ -1691,7 +1729,7 @@ public final class CSVFormat implements
*/
@Deprecated
public boolean getAllowDuplicateHeaderNames() {
-<span class="fc bfc" id="L1694" title="All 2 branches covered."> return
duplicateHeaderMode == DuplicateHeaderMode.ALLOW_ALL;</span>
+<span class="fc bfc" id="L1732" title="All 2 branches covered."> return
duplicateHeaderMode == DuplicateHeaderMode.ALLOW_ALL;</span>
}
/**
@@ -1700,7 +1738,7 @@ public final class CSVFormat implements
* @return {@code true} if missing column names are allowed when parsing
the header line, {@code false} to throw an {@link IllegalArgumentException}.
*/
public boolean getAllowMissingColumnNames() {
-<span class="fc" id="L1703"> return allowMissingColumnNames;</span>
+<span class="fc" id="L1741"> return allowMissingColumnNames;</span>
}
/**
@@ -1710,7 +1748,7 @@ public final class CSVFormat implements
* @since 1.6
*/
public boolean getAutoFlush() {
-<span class="fc" id="L1713"> return autoFlush;</span>
+<span class="fc" id="L1751"> return autoFlush;</span>
}
/**
@@ -1747,7 +1785,7 @@ public final class CSVFormat implements
* @return the comment start marker, may be {@code null}
*/
public Character getCommentMarker() {
-<span class="fc" id="L1750"> return commentMarker;</span>
+<span class="fc" id="L1788"> return commentMarker;</span>
}
/**
@@ -1758,7 +1796,7 @@ public final class CSVFormat implements
*/
@Deprecated
public char getDelimiter() {
-<span class="fc" id="L1761"> return delimiter.charAt(0);</span>
+<span class="fc" id="L1799"> return delimiter.charAt(0);</span>
}
/**
@@ -1767,7 +1805,7 @@ public final class CSVFormat implements
* @return the delimiter.
*/
char[] getDelimiterCharArray() {
-<span class="fc" id="L1770"> return delimiter.toCharArray();</span>
+<span class="fc" id="L1808"> return delimiter.toCharArray();</span>
}
/**
@@ -1777,7 +1815,7 @@ public final class CSVFormat implements
* @since 1.9.0
*/
public String getDelimiterString() {
-<span class="fc" id="L1780"> return delimiter;</span>
+<span class="fc" id="L1818"> return delimiter;</span>
}
/**
@@ -1787,7 +1825,7 @@ public final class CSVFormat implements
* @since 1.10.0
*/
public DuplicateHeaderMode getDuplicateHeaderMode() {
-<span class="fc" id="L1790"> return duplicateHeaderMode;</span>
+<span class="fc" id="L1828"> return duplicateHeaderMode;</span>
}
/**
@@ -1796,7 +1834,7 @@ public final class CSVFormat implements
* @return the escape character, may be {@code 0}
*/
char getEscapeChar() {
-<span class="pc bpc" id="L1799" title="1 of 2 branches missed."> return
escapeCharacter != null ? escapeCharacter.charValue() : 0; // N.B. Explicit
(un)boxing is intentional</span>
+<span class="pc bpc" id="L1837" title="1 of 2 branches missed."> return
escapeCharacter != null ? escapeCharacter.charValue() : 0; // Explicit
(un)boxing is intentional</span>
}
/**
@@ -1805,7 +1843,7 @@ public final class CSVFormat implements
* @return the escape character, may be {@code null}
*/
public Character getEscapeCharacter() {
-<span class="fc" id="L1808"> return escapeCharacter;</span>
+<span class="fc" id="L1846"> return escapeCharacter;</span>
}
/**
@@ -1814,7 +1852,7 @@ public final class CSVFormat implements
* @return a copy of the header array; {@code null} if disabled, the empty
array if to be read from the file
*/
public String[] getHeader() {
-<span class="fc bfc" id="L1817" title="All 2 branches covered."> return
headers != null ? headers.clone() : null;</span>
+<span class="fc bfc" id="L1855" title="All 2 branches covered."> return
headers != null ? headers.clone() : null;</span>
}
/**
@@ -1851,7 +1889,7 @@ public final class CSVFormat implements
* @return a copy of the header comment array; {@code null} if disabled.
*/
public String[] getHeaderComments() {
-<span class="fc bfc" id="L1854" title="All 2 branches covered."> return
headerComments != null ? headerComments.clone() : null;</span>
+<span class="fc bfc" id="L1892" title="All 2 branches covered."> return
headerComments != null ? headerComments.clone() : null;</span>
}
/**
@@ -1860,7 +1898,7 @@ public final class CSVFormat implements
* @return {@code true} if empty lines between records are ignored, {@code
false} if they are turned into empty records.
*/
public boolean getIgnoreEmptyLines() {
-<span class="fc" id="L1863"> return ignoreEmptyLines;</span>
+<span class="fc" id="L1901"> return ignoreEmptyLines;</span>
}
/**
@@ -1870,7 +1908,7 @@ public final class CSVFormat implements
* @since 1.3
*/
public boolean getIgnoreHeaderCase() {
-<span class="fc" id="L1873"> return ignoreHeaderCase;</span>
+<span class="fc" id="L1911"> return ignoreHeaderCase;</span>
}
/**
@@ -1879,7 +1917,7 @@ public final class CSVFormat implements
* @return {@code true} if spaces around values are ignored, {@code false}
if they are treated as part of the value.
*/
public boolean getIgnoreSurroundingSpaces() {
-<span class="fc" id="L1882"> return ignoreSurroundingSpaces;</span>
+<span class="fc" id="L1920"> return ignoreSurroundingSpaces;</span>
}
/**
@@ -1889,7 +1927,20 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public boolean getLenientEof() {
-<span class="fc" id="L1892"> return lenientEof;</span>
+<span class="fc" id="L1930"> return lenientEof;</span>
+ }
+
+ /**
+ * Gets the maximum number of rows to process, excluding the header row.
+ * <p>
+ * Values less than or equal to 0 mean no limit.
+ * </p>
+ *
+ * @return The maximum number of rows to process, excluding the header row.
+ * @since 1.14.0
+ */
+ public long getMaxRows() {
+<span class="fc" id="L1943"> return maxRows;</span>
}
/**
@@ -1902,7 +1953,7 @@ public final class CSVFormat implements
* @return the String to convert to and from {@code null}. No substitution
occurs if {@code null}
*/
public String getNullString() {
-<span class="fc" id="L1905"> return nullString;</span>
+<span class="fc" id="L1956"> return nullString;</span>
}
/**
@@ -1911,7 +1962,7 @@ public final class CSVFormat implements
* @return the quoteChar character, may be {@code null}
*/
public Character getQuoteCharacter() {
-<span class="fc" id="L1914"> return quoteCharacter;</span>
+<span class="fc" id="L1965"> return quoteCharacter;</span>
}
/**
@@ -1920,7 +1971,7 @@ public final class CSVFormat implements
* @return the quote policy
*/
public QuoteMode getQuoteMode() {
-<span class="fc" id="L1923"> return quoteMode;</span>
+<span class="fc" id="L1974"> return quoteMode;</span>
}
/**
@@ -1929,7 +1980,7 @@ public final class CSVFormat implements
* @return the record separator
*/
public String getRecordSeparator() {
-<span class="fc" id="L1932"> return recordSeparator;</span>
+<span class="fc" id="L1983"> return recordSeparator;</span>
}
/**
@@ -1938,7 +1989,7 @@ public final class CSVFormat implements
* @return whether to skip the header record.
*/
public boolean getSkipHeaderRecord() {
-<span class="fc" id="L1941"> return skipHeaderRecord;</span>
+<span class="fc" id="L1992"> return skipHeaderRecord;</span>
}
/**
@@ -1948,7 +1999,7 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public boolean getTrailingData() {
-<span class="fc" id="L1951"> return trailingData;</span>
+<span class="fc" id="L2002"> return trailingData;</span>
}
/**
@@ -1958,7 +2009,7 @@ public final class CSVFormat implements
* @since 1.3
*/
public boolean getTrailingDelimiter() {
-<span class="fc" id="L1961"> return trailingDelimiter;</span>
+<span class="fc" id="L2012"> return trailingDelimiter;</span>
}
/**
@@ -1967,19 +2018,18 @@ public final class CSVFormat implements
* @return whether to trim leading and trailing blanks.
*/
public boolean getTrim() {
-<span class="fc" id="L1970"> return trim;</span>
+<span class="fc" id="L2021"> return trim;</span>
}
@Override
public int hashCode() {
-<span class="fc" id="L1975"> final int prime = 31;</span>
-<span class="fc" id="L1976"> int result = 1;</span>
-<span class="fc" id="L1977"> result = prime * result +
Arrays.hashCode(headerComments);</span>
-<span class="fc" id="L1978"> result = prime * result +
Arrays.hashCode(headers);</span>
-<span class="fc" id="L1979"> result = prime * result +
Objects.hash(allowMissingColumnNames, autoFlush, commentMarker, delimiter,
duplicateHeaderMode, escapeCharacter,</span>
-<span class="fc" id="L1980"> ignoreEmptyLines,
ignoreHeaderCase, ignoreSurroundingSpaces, lenientEof, nullString,
quoteCharacter, quoteMode, quotedNullString,</span>
-<span class="fc" id="L1981"> recordSeparator, skipHeaderRecord,
trailingData, trailingDelimiter, trim);</span>
-<span class="fc" id="L1982"> return result;</span>
+<span class="fc" id="L2026"> final int prime = 31;</span>
+<span class="fc" id="L2027"> int result = 1;</span>
+<span class="fc" id="L2028"> result = prime * result +
Arrays.hashCode(headerComments);</span>
+<span class="fc" id="L2029"> result = prime * result +
Arrays.hashCode(headers);</span>
+<span class="fc" id="L2030"> return prime * result +
Objects.hash(allowMissingColumnNames, autoFlush, commentMarker, delimiter,
duplicateHeaderMode, escapeCharacter,</span>
+<span class="fc" id="L2031"> ignoreEmptyLines,
ignoreHeaderCase, ignoreSurroundingSpaces, lenientEof, nullString,
quoteCharacter, quoteMode, quotedNullString,</span>
+<span class="fc" id="L2032"> recordSeparator, skipHeaderRecord,
trailingData, trailingDelimiter, trim);</span>
}
/**
@@ -1990,7 +2040,7 @@ public final class CSVFormat implements
* @return {@code true} is comments are supported, {@code false} otherwise
*/
public boolean isCommentMarkerSet() {
-<span class="fc bfc" id="L1993" title="All 2 branches covered."> return
commentMarker != null;</span>
+<span class="fc bfc" id="L2043" title="All 2 branches covered."> return
commentMarker != null;</span>
}
/**
@@ -2004,19 +2054,19 @@ public final class CSVFormat implements
* @return true if the match is successful
*/
private boolean isDelimiter(final char ch0, final CharSequence charSeq,
final int startIndex, final char[] delimiter, final int delimiterLength) {
-<span class="fc bfc" id="L2007" title="All 2 branches covered."> if
(ch0 != delimiter[0]) {</span>
-<span class="fc" id="L2008"> return false;</span>
+<span class="fc bfc" id="L2057" title="All 2 branches covered."> if
(ch0 != delimiter[0]) {</span>
+<span class="fc" id="L2058"> return false;</span>
}
-<span class="fc" id="L2010"> final int len = charSeq.length();</span>
-<span class="fc bfc" id="L2011" title="All 2 branches covered."> if
(startIndex + delimiterLength > len) {</span>
-<span class="fc" id="L2012"> return false;</span>
- }
-<span class="fc bfc" id="L2014" title="All 2 branches covered."> for
(int i = 1; i < delimiterLength; i++) {</span>
-<span class="fc bfc" id="L2015" title="All 2 branches covered."> if
(charSeq.charAt(startIndex + i) != delimiter[i]) {</span>
-<span class="fc" id="L2016"> return false;</span>
+<span class="fc" id="L2060"> final int len = charSeq.length();</span>
+<span class="fc bfc" id="L2061" title="All 2 branches covered."> if
(startIndex + delimiterLength > len) {</span>
+<span class="fc" id="L2062"> return false;</span>
+ }
+<span class="fc bfc" id="L2064" title="All 2 branches covered."> for
(int i = 1; i < delimiterLength; i++) {</span>
+<span class="fc bfc" id="L2065" title="All 2 branches covered."> if
(charSeq.charAt(startIndex + i) != delimiter[i]) {</span>
+<span class="fc" id="L2066"> return false;</span>
}
}
-<span class="fc" id="L2019"> return true;</span>
+<span class="fc" id="L2069"> return true;</span>
}
/**
@@ -2025,7 +2075,7 @@ public final class CSVFormat implements
* @return {@code true} if escapes are processed
*/
public boolean isEscapeCharacterSet() {
-<span class="fc bfc" id="L2028" title="All 2 branches covered."> return
escapeCharacter != null;</span>
+<span class="fc bfc" id="L2078" title="All 2 branches covered."> return
escapeCharacter != null;</span>
}
/**
@@ -2034,7 +2084,7 @@ public final class CSVFormat implements
* @return {@code true} if a nullString is defined
[... 1087 lines stripped ...]