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 Sep 25 02:11:29 2024
@@ -17,25 +17,12 @@
package org.apache.commons.csv;
-import static org.apache.commons.csv.Constants.BACKSLASH;
-import static org.apache.commons.csv.Constants.COMMA;
-import static org.apache.commons.csv.Constants.COMMENT;
-import static org.apache.commons.csv.Constants.CR;
-import static org.apache.commons.csv.Constants.CRLF;
-import static org.apache.commons.csv.Constants.DOUBLE_QUOTE_CHAR;
-import static org.apache.commons.csv.Constants.EMPTY;
-import static org.apache.commons.csv.Constants.LF;
-import static org.apache.commons.csv.Constants.PIPE;
-import static org.apache.commons.csv.Constants.SP;
-import static org.apache.commons.csv.Constants.TAB;
import static org.apache.commons.io.IOUtils.EOF;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringWriter;
@@ -102,9 +89,9 @@ import org.apache.commons.io.output.Appe
* You can extend a format by calling the {@code set} methods. For example:
* </p>
*
- * <pre>
- *
CSVFormat.EXCEL.withNullString(&quot;N/A&quot;).withIgnoreSurroundingSpaces(true);
- * </pre>
+ * <pre>{@code
+ *
CSVFormat.EXCEL.withNullString("N/A").withIgnoreSurroundingSpaces(true);
+ * }</pre>
*
* <h2>Defining column names</h2>
*
@@ -112,9 +99,9 @@ import org.apache.commons.io.output.Appe
* To define the column names you want to use to access records, write:
* </p>
*
- * <pre>
- * CSVFormat.EXCEL.withHeader(&quot;Col1&quot;,
&quot;Col2&quot;, &quot;Col3&quot;);
- * </pre>
+ * <pre>{@code
+ * CSVFormat.EXCEL.withHeader("Col1", "Col2",
"Col3");
+ * }</pre>
*
* <p>
* Calling {@link Builder#setHeader(String...)} lets you use the given names
to address values in a {@link CSVRecord}, and assumes that your CSV source does
not
@@ -130,10 +117,10 @@ import org.apache.commons.io.output.Appe
* You can use a format directly to parse a reader. For example, to parse an
Excel file with columns header, write:
* </p>
*
- * <pre>
+ * <pre>{@code
* Reader in = ...;
- * CSVFormat.EXCEL.withHeader(&quot;Col1&quot;,
&quot;Col2&quot;, &quot;Col3&quot;).parse(in);
- * </pre>
+ * CSVFormat.EXCEL.withHeader("Col1", "Col2",
"Col3").parse(in);
+ * }</pre>
*
* <p>
* For other input types, like resources, files, and URLs, use the static
methods on {@link CSVParser}.
@@ -156,9 +143,9 @@ import org.apache.commons.io.output.Appe
* Then, call one of the {@link CSVRecord} get method that takes a String
column name argument:
* </p>
*
- * <pre>
- * String value = record.get(&quot;Col1&quot;);
- * </pre>
+ * <pre>{@code
+ * String value = record.get("Col1");
+ * }</pre>
*
* <p>
* This makes your code impervious to changes in column order in the CSV file.
@@ -203,7 +190,7 @@ public final class CSVFormat implements
* @return a copy of the builder
*/
public static Builder create() {
-<span class="fc" id="L206"> return new
Builder(CSVFormat.DEFAULT);</span>
+<span class="fc" id="L193"> return new Builder(DEFAULT);</span>
}
/**
@@ -213,7 +200,7 @@ public final class CSVFormat implements
* @return a copy of the builder
*/
public static Builder create(final CSVFormat csvFormat) {
-<span class="fc" id="L216"> return new Builder(csvFormat);</span>
+<span class="fc" id="L203"> return new Builder(csvFormat);</span>
}
private boolean allowMissingColumnNames;
@@ -258,29 +245,29 @@ public final class CSVFormat implements
private boolean trim;
-<span class="fc" id="L261"> private Builder(final CSVFormat csvFormat)
{</span>
-<span class="fc" id="L262"> this.delimiter =
csvFormat.delimiter;</span>
-<span class="fc" id="L263"> this.quoteCharacter =
csvFormat.quoteCharacter;</span>
-<span class="fc" id="L264"> this.quoteMode =
csvFormat.quoteMode;</span>
-<span class="fc" id="L265"> this.commentMarker =
csvFormat.commentMarker;</span>
-<span class="fc" id="L266"> this.escapeCharacter =
csvFormat.escapeCharacter;</span>
-<span class="fc" id="L267"> this.ignoreSurroundingSpaces =
csvFormat.ignoreSurroundingSpaces;</span>
-<span class="fc" id="L268"> this.allowMissingColumnNames =
csvFormat.allowMissingColumnNames;</span>
-<span class="fc" id="L269"> this.ignoreEmptyLines =
csvFormat.ignoreEmptyLines;</span>
-<span class="fc" id="L270"> this.recordSeparator =
csvFormat.recordSeparator;</span>
-<span class="fc" id="L271"> this.nullString =
csvFormat.nullString;</span>
-<span class="fc" id="L272"> this.headerComments =
csvFormat.headerComments;</span>
-<span class="fc" id="L273"> this.headers = csvFormat.headers;</span>
-<span class="fc" id="L274"> this.skipHeaderRecord =
csvFormat.skipHeaderRecord;</span>
-<span class="fc" id="L275"> this.ignoreHeaderCase =
csvFormat.ignoreHeaderCase;</span>
-<span class="fc" id="L276"> this.lenientEof =
csvFormat.lenientEof;</span>
-<span class="fc" id="L277"> this.trailingData =
csvFormat.trailingData;</span>
-<span class="fc" id="L278"> this.trailingDelimiter =
csvFormat.trailingDelimiter;</span>
-<span class="fc" id="L279"> this.trim = csvFormat.trim;</span>
-<span class="fc" id="L280"> this.autoFlush =
csvFormat.autoFlush;</span>
-<span class="fc" id="L281"> this.quotedNullString =
csvFormat.quotedNullString;</span>
-<span class="fc" id="L282"> this.duplicateHeaderMode =
csvFormat.duplicateHeaderMode;</span>
-<span class="fc" id="L283"> }</span>
+<span class="fc" id="L248"> private Builder(final CSVFormat csvFormat)
{</span>
+<span class="fc" id="L249"> this.delimiter =
csvFormat.delimiter;</span>
+<span class="fc" id="L250"> this.quoteCharacter =
csvFormat.quoteCharacter;</span>
+<span class="fc" id="L251"> this.quoteMode =
csvFormat.quoteMode;</span>
+<span class="fc" id="L252"> this.commentMarker =
csvFormat.commentMarker;</span>
+<span class="fc" id="L253"> this.escapeCharacter =
csvFormat.escapeCharacter;</span>
+<span class="fc" id="L254"> this.ignoreSurroundingSpaces =
csvFormat.ignoreSurroundingSpaces;</span>
+<span class="fc" id="L255"> this.allowMissingColumnNames =
csvFormat.allowMissingColumnNames;</span>
+<span class="fc" id="L256"> this.ignoreEmptyLines =
csvFormat.ignoreEmptyLines;</span>
+<span class="fc" id="L257"> this.recordSeparator =
csvFormat.recordSeparator;</span>
+<span class="fc" id="L258"> this.nullString =
csvFormat.nullString;</span>
+<span class="fc" id="L259"> this.headerComments =
csvFormat.headerComments;</span>
+<span class="fc" id="L260"> this.headers = csvFormat.headers;</span>
+<span class="fc" id="L261"> this.skipHeaderRecord =
csvFormat.skipHeaderRecord;</span>
+<span class="fc" id="L262"> this.ignoreHeaderCase =
csvFormat.ignoreHeaderCase;</span>
+<span class="fc" id="L263"> this.lenientEof =
csvFormat.lenientEof;</span>
+<span class="fc" id="L264"> this.trailingData =
csvFormat.trailingData;</span>
+<span class="fc" id="L265"> this.trailingDelimiter =
csvFormat.trailingDelimiter;</span>
+<span class="fc" id="L266"> this.trim = csvFormat.trim;</span>
+<span class="fc" id="L267"> this.autoFlush =
csvFormat.autoFlush;</span>
+<span class="fc" id="L268"> this.quotedNullString =
csvFormat.quotedNullString;</span>
+<span class="fc" id="L269"> this.duplicateHeaderMode =
csvFormat.duplicateHeaderMode;</span>
+<span class="fc" id="L270"> }</span>
/**
* Builds a new CSVFormat instance.
@@ -288,7 +275,7 @@ public final class CSVFormat implements
* @return a new CSVFormat instance.
*/
public CSVFormat build() {
-<span class="fc" id="L291"> return new CSVFormat(this);</span>
+<span class="fc" id="L278"> return new CSVFormat(this);</span>
}
/**
@@ -300,8 +287,8 @@ public final class CSVFormat implements
*/
@Deprecated
public Builder setAllowDuplicateHeaderNames(final boolean
allowDuplicateHeaderNames) {
-<span class="fc bfc" id="L303" title="All 2 branches covered.">
setDuplicateHeaderMode(allowDuplicateHeaderNames ?
DuplicateHeaderMode.ALLOW_ALL : DuplicateHeaderMode.ALLOW_EMPTY);</span>
-<span class="fc" id="L304"> return this;</span>
+<span class="fc bfc" id="L290" title="All 2 branches covered.">
setDuplicateHeaderMode(allowDuplicateHeaderNames ?
DuplicateHeaderMode.ALLOW_ALL : DuplicateHeaderMode.ALLOW_EMPTY);</span>
+<span class="fc" id="L291"> return this;</span>
}
/**
@@ -313,8 +300,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setAllowMissingColumnNames(final boolean
allowMissingColumnNames) {
-<span class="fc" id="L316"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
-<span class="fc" id="L317"> return this;</span>
+<span class="fc" id="L303"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
+<span class="fc" id="L304"> return this;</span>
}
/**
@@ -324,8 +311,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setAutoFlush(final boolean autoFlush) {
-<span class="fc" id="L327"> this.autoFlush = autoFlush;</span>
-<span class="fc" id="L328"> return this;</span>
+<span class="fc" id="L314"> this.autoFlush = autoFlush;</span>
+<span class="fc" id="L315"> return this;</span>
}
/**
@@ -363,8 +350,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="L366">
setCommentMarker(Character.valueOf(commentMarker));</span>
-<span class="fc" id="L367"> return this;</span>
+<span class="fc" id="L353">
setCommentMarker(Character.valueOf(commentMarker));</span>
+<span class="fc" id="L354"> return this;</span>
}
/**
@@ -402,11 +389,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="L405" title="All 2 branches covered."> if
(isLineBreak(commentMarker)) {</span>
-<span class="fc" id="L406"> throw new
IllegalArgumentException("The comment start marker character cannot be a
line break");</span>
+<span class="fc bfc" id="L392" title="All 2 branches covered."> if
(isLineBreak(commentMarker)) {</span>
+<span class="fc" id="L393"> throw new
IllegalArgumentException("The comment start marker character cannot be a
line break");</span>
}
-<span class="fc" id="L408"> this.commentMarker =
commentMarker;</span>
-<span class="fc" id="L409"> return this;</span>
+<span class="fc" id="L395"> this.commentMarker =
commentMarker;</span>
+<span class="fc" id="L396"> return this;</span>
}
/**
@@ -416,7 +403,7 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setDelimiter(final char delimiter) {
-<span class="fc" id="L419"> return
setDelimiter(String.valueOf(delimiter));</span>
+<span class="fc" id="L406"> return
setDelimiter(String.valueOf(delimiter));</span>
}
/**
@@ -426,14 +413,14 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setDelimiter(final String delimiter) {
-<span class="fc bfc" id="L429" title="All 2 branches covered."> if
(containsLineBreak(delimiter)) {</span>
-<span class="fc" id="L430"> throw new
IllegalArgumentException("The delimiter cannot be a line
break");</span>
+<span class="fc bfc" id="L416" title="All 2 branches covered."> if
(containsLineBreak(delimiter)) {</span>
+<span class="fc" id="L417"> throw new
IllegalArgumentException("The delimiter cannot be a line
break");</span>
}
-<span class="fc bfc" id="L432" title="All 2 branches covered."> if
(delimiter.isEmpty()) {</span>
-<span class="fc" id="L433"> throw new
IllegalArgumentException("The delimiter cannot be empty");</span>
+<span class="fc bfc" id="L419" title="All 2 branches covered."> if
(delimiter.isEmpty()) {</span>
+<span class="fc" id="L420"> throw new
IllegalArgumentException("The delimiter cannot be empty");</span>
}
-<span class="fc" id="L435"> this.delimiter = delimiter;</span>
-<span class="fc" id="L436"> return this;</span>
+<span class="fc" id="L422"> this.delimiter = delimiter;</span>
+<span class="fc" id="L423"> return this;</span>
}
/**
@@ -444,8 +431,8 @@ public final class CSVFormat implements
* @since 1.10.0
*/
public Builder setDuplicateHeaderMode(final DuplicateHeaderMode
duplicateHeaderMode) {
-<span class="fc" id="L447"> this.duplicateHeaderMode =
Objects.requireNonNull(duplicateHeaderMode,
"duplicateHeaderMode");</span>
-<span class="fc" id="L448"> return this;</span>
+<span class="fc" id="L434"> this.duplicateHeaderMode =
Objects.requireNonNull(duplicateHeaderMode,
"duplicateHeaderMode");</span>
+<span class="fc" id="L435"> return this;</span>
}
/**
@@ -456,8 +443,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="L459">
setEscape(Character.valueOf(escapeCharacter));</span>
-<span class="fc" id="L460"> return this;</span>
+<span class="fc" id="L446">
setEscape(Character.valueOf(escapeCharacter));</span>
+<span class="fc" id="L447"> return this;</span>
}
/**
@@ -468,11 +455,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="L471" title="All 2 branches covered."> if
(isLineBreak(escapeCharacter)) {</span>
-<span class="fc" id="L472"> throw new
IllegalArgumentException("The escape character cannot be a line
break");</span>
+<span class="fc bfc" id="L458" title="All 2 branches covered."> if
(isLineBreak(escapeCharacter)) {</span>
+<span class="fc" id="L459"> throw new
IllegalArgumentException("The escape character cannot be a line
break");</span>
}
-<span class="fc" id="L474"> this.escapeCharacter =
escapeCharacter;</span>
-<span class="fc" id="L475"> return this;</span>
+<span class="fc" id="L461"> this.escapeCharacter =
escapeCharacter;</span>
+<span class="fc" id="L462"> return this;</span>
}
/**
@@ -497,13 +484,13 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setHeader(final Class<? extends Enum<?>>
headerEnum) {
-<span class="fc" id="L500"> String[] header = null;</span>
-<span class="fc bfc" id="L501" title="All 2 branches covered."> if
(headerEnum != null) {</span>
-<span class="fc" id="L502"> final Enum<?>[] enumValues =
headerEnum.getEnumConstants();</span>
-<span class="fc" id="L503"> header = new
String[enumValues.length];</span>
-<span class="fc" id="L504"> Arrays.setAll(header, i ->
enumValues[i].name());</span>
+<span class="fc" id="L487"> String[] header = null;</span>
+<span class="fc bfc" id="L488" title="All 2 branches covered."> if
(headerEnum != null) {</span>
+<span class="fc" id="L489"> final Enum<?>[] enumValues =
headerEnum.getEnumConstants();</span>
+<span class="fc" id="L490"> header = new
String[enumValues.length];</span>
+<span class="fc" id="L491"> Arrays.setAll(header, i ->
enumValues[i].name());</span>
}
-<span class="fc" id="L506"> return setHeader(header);</span>
+<span class="fc" id="L493"> return setHeader(header);</span>
}
/**
@@ -527,7 +514,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="L530" title="All 2 branches covered.">
return setHeader(resultSet != null ? resultSet.getMetaData() : null);</span>
+<span class="fc bfc" id="L517" title="All 2 branches covered.">
return setHeader(resultSet != null ? resultSet.getMetaData() : null);</span>
}
/**
@@ -551,15 +538,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="L554"> String[] labels = null;</span>
-<span class="fc bfc" id="L555" title="All 2 branches covered."> if
(resultSetMetaData != null) {</span>
-<span class="fc" id="L556"> final int columnCount =
resultSetMetaData.getColumnCount();</span>
-<span class="fc" id="L557"> labels = new
String[columnCount];</span>
-<span class="fc bfc" id="L558" title="All 2 branches covered.">
for (int i = 0; i < columnCount; i++) {</span>
-<span class="fc" id="L559"> labels[i] =
resultSetMetaData.getColumnLabel(i + 1);</span>
+<span class="fc" id="L541"> String[] labels = null;</span>
+<span class="fc bfc" id="L542" title="All 2 branches covered."> if
(resultSetMetaData != null) {</span>
+<span class="fc" id="L543"> final int columnCount =
resultSetMetaData.getColumnCount();</span>
+<span class="fc" id="L544"> labels = new
String[columnCount];</span>
+<span class="fc bfc" id="L545" title="All 2 branches covered.">
for (int i = 0; i < columnCount; i++) {</span>
+<span class="fc" id="L546"> labels[i] =
resultSetMetaData.getColumnLabel(i + 1);</span>
}
}
-<span class="fc" id="L562"> return setHeader(labels);</span>
+<span class="fc" id="L549"> return setHeader(labels);</span>
}
/**
@@ -571,9 +558,9 @@ public final class CSVFormat implements
*
* or specified manually with:
*
- * <pre>
- * builder.setHeader(&quot;name&quot;,
&quot;email&quot;, &quot;phone&quot;);
- * </pre>
+ * <pre>{@code
+ * builder.setHeader("name", "email",
"phone");
+ * }</pre>
* <p>
* The header is also used by the {@link CSVPrinter}.
* </p>
@@ -582,8 +569,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setHeader(final String... header) {
-<span class="fc" id="L585"> this.headers =
CSVFormat.clone(header);</span>
-<span class="fc" id="L586"> return this;</span>
+<span class="fc" id="L572"> this.headers =
CSVFormat.clone(header);</span>
+<span class="fc" id="L573"> return this;</span>
}
/**
@@ -620,8 +607,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setHeaderComments(final Object... headerComments) {
-<span class="fc" id="L623"> this.headerComments =
CSVFormat.clone(toStringArray(headerComments));</span>
-<span class="fc" id="L624"> return this;</span>
+<span class="fc" id="L610"> this.headerComments =
CSVFormat.clone(toStringArray(headerComments));</span>
+<span class="fc" id="L611"> return this;</span>
}
/**
@@ -658,8 +645,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setHeaderComments(final String... headerComments) {
-<span class="fc" id="L661"> this.headerComments =
CSVFormat.clone(headerComments);</span>
-<span class="fc" id="L662"> return this;</span>
+<span class="fc" id="L648"> this.headerComments =
CSVFormat.clone(headerComments);</span>
+<span class="fc" id="L649"> return this;</span>
}
/**
@@ -671,8 +658,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreEmptyLines(final boolean ignoreEmptyLines) {
-<span class="fc" id="L674"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
-<span class="fc" id="L675"> return this;</span>
+<span class="fc" id="L661"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
+<span class="fc" id="L662"> return this;</span>
}
/**
@@ -682,8 +669,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreHeaderCase(final boolean ignoreHeaderCase) {
-<span class="fc" id="L685"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
-<span class="fc" id="L686"> return this;</span>
+<span class="fc" id="L672"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
+<span class="fc" id="L673"> return this;</span>
}
/**
@@ -693,8 +680,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setIgnoreSurroundingSpaces(final boolean
ignoreSurroundingSpaces) {
-<span class="fc" id="L696"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
-<span class="fc" id="L697"> return this;</span>
+<span class="fc" id="L683"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
+<span class="fc" id="L684"> return this;</span>
}
/**
@@ -705,8 +692,8 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public Builder setLenientEof(final boolean lenientEof) {
-<span class="fc" id="L708"> this.lenientEof = lenientEof;</span>
-<span class="fc" id="L709"> return this;</span>
+<span class="fc" id="L695"> this.lenientEof = lenientEof;</span>
+<span class="fc" id="L696"> return this;</span>
}
/**
@@ -721,9 +708,9 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setNullString(final String nullString) {
-<span class="fc" id="L724"> this.nullString = nullString;</span>
-<span class="fc" id="L725"> this.quotedNullString = quoteCharacter
+ nullString + quoteCharacter;</span>
-<span class="fc" id="L726"> return this;</span>
+<span class="fc" id="L711"> this.nullString = nullString;</span>
+<span class="fc" id="L712"> this.quotedNullString = quoteCharacter
+ nullString + quoteCharacter;</span>
+<span class="fc" id="L713"> return this;</span>
}
/**
@@ -733,8 +720,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuote(final char quoteCharacter) {
-<span class="fc" id="L736">
setQuote(Character.valueOf(quoteCharacter));</span>
-<span class="fc" id="L737"> return this;</span>
+<span class="fc" id="L723">
setQuote(Character.valueOf(quoteCharacter));</span>
+<span class="fc" id="L724"> return this;</span>
}
/**
@@ -744,11 +731,11 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuote(final Character quoteCharacter) {
-<span class="fc bfc" id="L747" title="All 2 branches covered."> if
(isLineBreak(quoteCharacter)) {</span>
-<span class="fc" id="L748"> throw new
IllegalArgumentException("The quoteChar cannot be a line
break");</span>
+<span class="fc bfc" id="L734" title="All 2 branches covered."> if
(isLineBreak(quoteCharacter)) {</span>
+<span class="fc" id="L735"> throw new
IllegalArgumentException("The quoteChar cannot be a line
break");</span>
}
-<span class="fc" id="L750"> this.quoteCharacter =
quoteCharacter;</span>
-<span class="fc" id="L751"> return this;</span>
+<span class="fc" id="L737"> this.quoteCharacter =
quoteCharacter;</span>
+<span class="fc" id="L738"> return this;</span>
}
/**
@@ -758,8 +745,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setQuoteMode(final QuoteMode quoteMode) {
-<span class="fc" id="L761"> this.quoteMode = quoteMode;</span>
-<span class="fc" id="L762"> return this;</span>
+<span class="fc" id="L748"> this.quoteMode = quoteMode;</span>
+<span class="fc" id="L749"> return this;</span>
}
/**
@@ -774,8 +761,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setRecordSeparator(final char recordSeparator) {
-<span class="fc" id="L777"> this.recordSeparator =
String.valueOf(recordSeparator);</span>
-<span class="fc" id="L778"> return this;</span>
+<span class="fc" id="L764"> this.recordSeparator =
String.valueOf(recordSeparator);</span>
+<span class="fc" id="L765"> return this;</span>
}
/**
@@ -790,8 +777,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setRecordSeparator(final String recordSeparator) {
-<span class="fc" id="L793"> this.recordSeparator =
recordSeparator;</span>
-<span class="fc" id="L794"> return this;</span>
+<span class="fc" id="L780"> this.recordSeparator =
recordSeparator;</span>
+<span class="fc" id="L781"> return this;</span>
}
/**
@@ -801,8 +788,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setSkipHeaderRecord(final boolean skipHeaderRecord) {
-<span class="fc" id="L804"> this.skipHeaderRecord =
skipHeaderRecord;</span>
-<span class="fc" id="L805"> return this;</span>
+<span class="fc" id="L791"> this.skipHeaderRecord =
skipHeaderRecord;</span>
+<span class="fc" id="L792"> return this;</span>
}
/**
@@ -813,8 +800,8 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public Builder setTrailingData(final boolean trailingData) {
-<span class="fc" id="L816"> this.trailingData = trailingData;</span>
-<span class="fc" id="L817"> return this;</span>
+<span class="fc" id="L803"> this.trailingData = trailingData;</span>
+<span class="fc" id="L804"> return this;</span>
}
/**
@@ -824,8 +811,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setTrailingDelimiter(final boolean trailingDelimiter) {
-<span class="fc" id="L827"> this.trailingDelimiter =
trailingDelimiter;</span>
-<span class="fc" id="L828"> return this;</span>
+<span class="fc" id="L814"> this.trailingDelimiter =
trailingDelimiter;</span>
+<span class="fc" id="L815"> return this;</span>
}
/**
@@ -835,8 +822,8 @@ public final class CSVFormat implements
* @return This instance.
*/
public Builder setTrim(final boolean trim) {
-<span class="fc" id="L838"> this.trim = trim;</span>
-<span class="fc" id="L839"> return this;</span>
+<span class="fc" id="L825"> this.trim = trim;</span>
+<span class="fc" id="L826"> return this;</span>
}
}
@@ -845,78 +832,102 @@ public final class CSVFormat implements
*
* @since 1.2
*/
-<span class="fc" id="L848"> public enum Predefined {</span>
+<span class="fc" id="L835"> public enum Predefined {</span>
/**
+ * The DEFAULT predefined format.
+ *
* @see CSVFormat#DEFAULT
*/
-<span class="fc" id="L853"> Default(CSVFormat.DEFAULT),</span>
+<span class="fc" id="L842"> Default(DEFAULT),</span>
/**
+ * The EXCEL predefined format.
+ *
* @see CSVFormat#EXCEL
*/
-<span class="fc" id="L858"> Excel(CSVFormat.EXCEL),</span>
+<span class="fc" id="L849"> Excel(EXCEL),</span>
/**
+ * The INFORMIX_UNLOAD predefined format.
+ *
* @see CSVFormat#INFORMIX_UNLOAD
* @since 1.3
*/
-<span class="fc" id="L864">
InformixUnload(CSVFormat.INFORMIX_UNLOAD),</span>
+<span class="fc" id="L857"> InformixUnload(INFORMIX_UNLOAD),</span>
/**
+ * The INFORMIX_UNLOAD_CSV predefined format.
+ *
* @see CSVFormat#INFORMIX_UNLOAD_CSV
* @since 1.3
*/
-<span class="fc" id="L870">
InformixUnloadCsv(CSVFormat.INFORMIX_UNLOAD_CSV),</span>
+<span class="fc" id="L865">
InformixUnloadCsv(INFORMIX_UNLOAD_CSV),</span>
/**
+ * The MONGODB_CSV predefined format.
+ *
* @see CSVFormat#MONGODB_CSV
* @since 1.7
*/
-<span class="fc" id="L876"> MongoDBCsv(CSVFormat.MONGODB_CSV),</span>
+<span class="fc" id="L873"> MongoDBCsv(MONGODB_CSV),</span>
/**
+ * The MONGODB_TSV predefined format.
+ *
* @see CSVFormat#MONGODB_TSV
* @since 1.7
*/
-<span class="fc" id="L882"> MongoDBTsv(CSVFormat.MONGODB_TSV),</span>
+<span class="fc" id="L881"> MongoDBTsv(MONGODB_TSV),</span>
/**
+ * The MYSQL predefined format.
+ *
* @see CSVFormat#MYSQL
*/
-<span class="fc" id="L887"> MySQL(CSVFormat.MYSQL),</span>
+<span class="fc" id="L888"> MySQL(MYSQL),</span>
/**
+ * The ORACLE predefined format.
+ *
* @see CSVFormat#ORACLE
*/
-<span class="fc" id="L892"> Oracle(CSVFormat.ORACLE),</span>
+<span class="fc" id="L895"> Oracle(ORACLE),</span>
/**
+ * The POSTGRESQL_CSV predefined format.
+ *
* @see CSVFormat#POSTGRESQL_CSV
* @since 1.5
*/
-<span class="fc" id="L898">
PostgreSQLCsv(CSVFormat.POSTGRESQL_CSV),</span>
+<span class="fc" id="L903"> PostgreSQLCsv(POSTGRESQL_CSV),</span>
/**
- * @see CSVFormat#POSTGRESQL_CSV
+ * The POSTGRESQL_TEXT predefined format.
+ *
+ * @see CSVFormat#POSTGRESQL_TEXT
*/
-<span class="fc" id="L903">
PostgreSQLText(CSVFormat.POSTGRESQL_TEXT),</span>
+<span class="fc" id="L910"> PostgreSQLText(POSTGRESQL_TEXT),</span>
/**
+ * The RFC4180 predefined format.
+ *
* @see CSVFormat#RFC4180
*/
-<span class="fc" id="L908"> RFC4180(CSVFormat.RFC4180),</span>
+<span class="fc" id="L917"> RFC4180(CSVFormat.RFC4180),</span>
/**
+ * The TDF predefined format.
+ *
* @see CSVFormat#TDF
*/
-<span class="fc" id="L913"> TDF(CSVFormat.TDF);</span>
+<span class="fc" id="L924"> TDF(CSVFormat.TDF);</span>
private final CSVFormat format;
-<span class="fc" id="L917"> Predefined(final CSVFormat format) {</span>
-<span class="fc" id="L918"> this.format = format;</span>
-<span class="fc" id="L919"> }</span>
+<span class="fc" id="L928"> Predefined(final CSVFormat format) {</span>
+<span class="fc" id="L929"> this.format = format;</span>
+<span class="fc" id="L930"> }</span>
/**
* Gets the format.
@@ -924,7 +935,7 @@ public final class CSVFormat implements
* @return the format.
*/
public CSVFormat getFormat() {
-<span class="fc" id="L927"> return format;</span>
+<span class="fc" id="L938"> return format;</span>
}
}
@@ -945,8 +956,8 @@ public final class CSVFormat implements
*
* @see Predefined#Default
*/
-<span class="fc" id="L948"> public static final CSVFormat DEFAULT = new
CSVFormat(COMMA, DOUBLE_QUOTE_CHAR, null, null, null, false, true, CRLF, null,
null, null, false, false, false,</span>
- false, false, false, DuplicateHeaderMode.ALLOW_ALL, false, false);
+<span class="fc" id="L959"> public static final CSVFormat DEFAULT = new
CSVFormat(Constants.COMMA, Constants.DOUBLE_QUOTE_CHAR, null, null, null,
false, true, Constants.CRLF, null,</span>
+ null, null, false, false, false, false, false, false,
DuplicateHeaderMode.ALLOW_ALL, false, false);
/**
* 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
@@ -981,12 +992,12 @@ public final class CSVFormat implements
* @see Predefined#Excel
*/
// @formatter:off
-<span class="fc" id="L984"> public static final CSVFormat EXCEL =
DEFAULT.builder()</span>
-<span class="fc" id="L985"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L986"> .setAllowMissingColumnNames(true)</span>
-<span class="fc" id="L987"> .setTrailingData(true)</span>
-<span class="fc" id="L988"> .setLenientEof(true)</span>
-<span class="fc" id="L989"> .build();</span>
+<span class="fc" id="L995"> public static final CSVFormat EXCEL =
DEFAULT.builder()</span>
+<span class="fc" id="L996"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L997"> .setAllowMissingColumnNames(true)</span>
+<span class="fc" id="L998"> .setTrailingData(true)</span>
+<span class="fc" id="L999"> .setLenientEof(true)</span>
+<span class="fc" id="L1000"> .build();</span>
// @formatter:on
/**
@@ -1013,12 +1024,12 @@ public final class CSVFormat implements
* @since 1.3
*/
// @formatter:off
-<span class="fc" id="L1016"> public static final CSVFormat INFORMIX_UNLOAD
= DEFAULT.builder()</span>
-<span class="fc" id="L1017"> .setDelimiter(PIPE)</span>
-<span class="fc" id="L1018"> .setEscape(BACKSLASH)</span>
-<span class="fc" id="L1019"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1020"> .setRecordSeparator(LF)</span>
-<span class="fc" id="L1021"> .build();</span>
+<span class="fc" id="L1027"> public static final CSVFormat INFORMIX_UNLOAD
= DEFAULT.builder()</span>
+<span class="fc" id="L1028"> .setDelimiter(Constants.PIPE)</span>
+<span class="fc" id="L1029"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1030">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1031">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1032"> .build();</span>
// @formatter:on
/**
@@ -1044,11 +1055,11 @@ public final class CSVFormat implements
* @since 1.3
*/
// @formatter:off
-<span class="fc" id="L1047"> public static final CSVFormat
INFORMIX_UNLOAD_CSV = DEFAULT.builder()</span>
-<span class="fc" id="L1048"> .setDelimiter(COMMA)</span>
-<span class="fc" id="L1049"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1050"> .setRecordSeparator(LF)</span>
-<span class="fc" id="L1051"> .build();</span>
+<span class="fc" id="L1058"> public static final CSVFormat
INFORMIX_UNLOAD_CSV = DEFAULT.builder()</span>
+<span class="fc" id="L1059"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1060">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1061">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1062"> .build();</span>
// @formatter:on
/**
@@ -1084,13 +1095,13 @@ public final class CSVFormat implements
* @since 1.7
*/
// @formatter:off
-<span class="fc" id="L1087"> public static final CSVFormat MONGODB_CSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1088"> .setDelimiter(COMMA)</span>
-<span class="fc" id="L1089"> .setEscape(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1090"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1091"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1092"> .setSkipHeaderRecord(false)</span>
-<span class="fc" id="L1093"> .build();</span>
+<span class="fc" id="L1098"> public static final CSVFormat MONGODB_CSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1099"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1100">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1101">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1102"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1103"> .setSkipHeaderRecord(false)</span>
+<span class="fc" id="L1104"> .build();</span>
// @formatter:off
/**
@@ -1121,13 +1132,13 @@ public final class CSVFormat implements
* @since 1.7
*/
// @formatter:off
-<span class="fc" id="L1124"> public static final CSVFormat MONGODB_TSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1125"> .setDelimiter(TAB)</span>
-<span class="fc" id="L1126"> .setEscape(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1127"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1128"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1129"> .setSkipHeaderRecord(false)</span>
-<span class="fc" id="L1130"> .build();</span>
+<span class="fc" id="L1135"> public static final CSVFormat MONGODB_TSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1136"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1137">
.setEscape(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1138">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1139"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1140"> .setSkipHeaderRecord(false)</span>
+<span class="fc" id="L1141"> .build();</span>
// @formatter:off
/**
@@ -1156,15 +1167,15 @@ public final class CSVFormat implements
* -data.html</a>
*/
// @formatter:off
-<span class="fc" id="L1159"> public static final CSVFormat MYSQL =
DEFAULT.builder()</span>
-<span class="fc" id="L1160"> .setDelimiter(TAB)</span>
-<span class="fc" id="L1161"> .setEscape(BACKSLASH)</span>
-<span class="fc" id="L1162"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1163"> .setQuote(null)</span>
-<span class="fc" id="L1164"> .setRecordSeparator(LF)</span>
-<span class="fc" id="L1165">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1166">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1167"> .build();</span>
+<span class="fc" id="L1170"> public static final CSVFormat MYSQL =
DEFAULT.builder()</span>
+<span class="fc" id="L1171"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1172"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1173"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1174"> .setQuote(null)</span>
+<span class="fc" id="L1175">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1176">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1177">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1178"> .build();</span>
// @formatter:off
/**
@@ -1195,16 +1206,16 @@ public final class CSVFormat implements
* @since 1.6
*/
// @formatter:off
-<span class="fc" id="L1198"> public static final CSVFormat ORACLE =
DEFAULT.builder()</span>
-<span class="fc" id="L1199"> .setDelimiter(COMMA)</span>
-<span class="fc" id="L1200"> .setEscape(BACKSLASH)</span>
-<span class="fc" id="L1201"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1202"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1203">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1204"> .setTrim(true)</span>
-<span class="fc" id="L1205">
.setRecordSeparator(System.lineSeparator())</span>
-<span class="fc" id="L1206"> .setQuoteMode(QuoteMode.MINIMAL)</span>
-<span class="fc" id="L1207"> .build();</span>
+<span class="fc" id="L1209"> public static final CSVFormat ORACLE =
DEFAULT.builder()</span>
+<span class="fc" id="L1210"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1211"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1212"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1213">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1214">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1215"> .setTrim(true)</span>
+<span class="fc" id="L1216">
.setRecordSeparator(System.lineSeparator())</span>
+<span class="fc" id="L1217"> .setQuoteMode(QuoteMode.MINIMAL)</span>
+<span class="fc" id="L1218"> .build();</span>
// @formatter:off
/**
@@ -1234,15 +1245,15 @@ public final class CSVFormat implements
* @since 1.5
*/
// @formatter:off
-<span class="fc" id="L1237"> public static final CSVFormat POSTGRESQL_CSV =
DEFAULT.builder()</span>
-<span class="fc" id="L1238"> .setDelimiter(COMMA)</span>
-<span class="fc" id="L1239"> .setEscape(null)</span>
-<span class="fc" id="L1240"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1241"> .setQuote(DOUBLE_QUOTE_CHAR)</span>
-<span class="fc" id="L1242"> .setRecordSeparator(LF)</span>
-<span class="fc" id="L1243"> .setNullString(EMPTY)</span>
-<span class="fc" id="L1244">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1245"> .build();</span>
+<span class="fc" id="L1248"> public static final CSVFormat POSTGRESQL_CSV =
DEFAULT.builder()</span>
+<span class="fc" id="L1249"> .setDelimiter(Constants.COMMA)</span>
+<span class="fc" id="L1250"> .setEscape(null)</span>
+<span class="fc" id="L1251"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1252">
.setQuote(Constants.DOUBLE_QUOTE_CHAR)</span>
+<span class="fc" id="L1253">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1254"> .setNullString(Constants.EMPTY)</span>
+<span class="fc" id="L1255">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1256"> .build();</span>
// @formatter:off
/**
@@ -1272,15 +1283,15 @@ public final class CSVFormat implements
* @since 1.5
*/
// @formatter:off
-<span class="fc" id="L1275"> public static final CSVFormat POSTGRESQL_TEXT
= DEFAULT.builder()</span>
-<span class="fc" id="L1276"> .setDelimiter(TAB)</span>
-<span class="fc" id="L1277"> .setEscape(BACKSLASH)</span>
-<span class="fc" id="L1278"> .setIgnoreEmptyLines(false)</span>
-<span class="fc" id="L1279"> .setQuote(null)</span>
-<span class="fc" id="L1280"> .setRecordSeparator(LF)</span>
-<span class="fc" id="L1281">
.setNullString(Constants.SQL_NULL_STRING)</span>
-<span class="fc" id="L1282">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
-<span class="fc" id="L1283"> .build();</span>
+<span class="fc" id="L1286"> public static final CSVFormat POSTGRESQL_TEXT
= DEFAULT.builder()</span>
+<span class="fc" id="L1287"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1288"> .setEscape(Constants.BACKSLASH)</span>
+<span class="fc" id="L1289"> .setIgnoreEmptyLines(false)</span>
+<span class="fc" id="L1290"> .setQuote(null)</span>
+<span class="fc" id="L1291">
.setRecordSeparator(Constants.LF)</span>
+<span class="fc" id="L1292">
.setNullString(Constants.SQL_NULL_STRING)</span>
+<span class="fc" id="L1293">
.setQuoteMode(QuoteMode.ALL_NON_NULL)</span>
+<span class="fc" id="L1294"> .build();</span>
// @formatter:off
/**
@@ -1298,7 +1309,7 @@ public final class CSVFormat implements
*
* @see Predefined#RFC4180
*/
-<span class="fc" id="L1301"> public static final CSVFormat RFC4180 =
DEFAULT.builder().setIgnoreEmptyLines(false).build();</span>
+<span class="fc" id="L1312"> public static final CSVFormat RFC4180 =
DEFAULT.builder().setIgnoreEmptyLines(false).build();</span>
private static final long serialVersionUID = 2L;
@@ -1318,10 +1329,10 @@ public final class CSVFormat implements
* @see Predefined#TDF
*/
// @formatter:off
-<span class="fc" id="L1321"> public static final CSVFormat TDF =
DEFAULT.builder()</span>
-<span class="fc" id="L1322"> .setDelimiter(TAB)</span>
-<span class="fc" id="L1323">
.setIgnoreSurroundingSpaces(true)</span>
-<span class="fc" id="L1324"> .build();</span>
+<span class="fc" id="L1332"> public static final CSVFormat TDF =
DEFAULT.builder()</span>
+<span class="fc" id="L1333"> .setDelimiter(Constants.TAB)</span>
+<span class="fc" id="L1334">
.setIgnoreSurroundingSpaces(true)</span>
+<span class="fc" id="L1335"> .build();</span>
// @formatter:on
/**
@@ -1333,7 +1344,7 @@ public final class CSVFormat implements
*/
@SafeVarargs
static <T> T[] clone(final T... values) {
-<span class="fc bfc" id="L1336" title="All 2 branches covered."> return
values == null ? null : values.clone();</span>
+<span class="fc bfc" id="L1347" title="All 2 branches covered."> return
values == null ? null : values.clone();</span>
}
/**
@@ -1345,7 +1356,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="L1348" title="All 2 branches covered."> return
Objects.requireNonNull(source, "source").indexOf(searchCh) >=
0;</span>
+<span class="fc bfc" id="L1359" title="All 2 branches covered."> return
Objects.requireNonNull(source, "source").indexOf(searchCh) >=
0;</span>
}
/**
@@ -1356,11 +1367,11 @@ 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="L1359" title="All 4 branches covered."> return
contains(source, CR) || contains(source, LF);</span>
+<span class="fc bfc" id="L1370" title="All 4 branches covered."> return
contains(source, Constants.CR) || contains(source, Constants.LF);</span>
}
static boolean isBlank(final String value) {
-<span class="fc bfc" id="L1363" title="All 4 branches covered."> return
value == null || value.trim().isEmpty();</span>
+<span class="fc bfc" id="L1374" title="All 4 branches covered."> return
value == null || value.trim().isEmpty();</span>
}
/**
@@ -1371,7 +1382,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="L1374" title="All 4 branches covered."> return
c == LF || c == CR;</span>
+<span class="fc bfc" id="L1385" title="All 4 branches covered."> return
c == Constants.LF || c == Constants.CR;</span>
}
/**
@@ -1382,17 +1393,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="L1385" title="All 4 branches covered."> return
c != null && isLineBreak(c.charValue());</span>
+<span class="fc bfc" id="L1396" title="All 4 branches covered."> return
c != null && isLineBreak(c.charValue()); // N.B. 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="L1390" title="All 2 branches covered."> return
ch <= SP;</span>
+<span class="fc bfc" id="L1401" 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="L1395"> return
isTrimChar(charSequence.charAt(pos));</span>
+<span class="fc" id="L1406"> return
isTrimChar(charSequence.charAt(pos));</span>
}
/**
@@ -1413,34 +1424,34 @@ public final class CSVFormat implements
* @see #TDF
*/
public static CSVFormat newFormat(final char delimiter) {
-<span class="fc" id="L1416"> return new
CSVFormat(String.valueOf(delimiter), null, null, null, null, false, false,
null, null, null, null, false, false, false, false, false, false,</span>
+<span class="fc" id="L1427"> return new
CSVFormat(String.valueOf(delimiter), null, null, null, null, false, false,
null, null, null, null, false, false, false, false, false, false,</span>
DuplicateHeaderMode.ALLOW_ALL, false, false);
}
static String[] toStringArray(final Object[] values) {
-<span class="fc bfc" id="L1421" title="All 2 branches covered."> if
(values == null) {</span>
-<span class="fc" id="L1422"> return null;</span>
+<span class="fc bfc" id="L1432" title="All 2 branches covered."> if
(values == null) {</span>
+<span class="fc" id="L1433"> return null;</span>
}
-<span class="fc" id="L1424"> final String[] strings = new
String[values.length];</span>
-<span class="fc" id="L1425"> Arrays.setAll(strings, i ->
Objects.toString(values[i], null));</span>
-<span class="fc" id="L1426"> return strings;</span>
+<span class="fc" id="L1435"> final String[] strings = new
String[values.length];</span>
+<span class="fc" id="L1436"> Arrays.setAll(strings, i ->
Objects.toString(values[i], null));</span>
+<span class="fc" id="L1437"> return strings;</span>
}
static CharSequence trim(final CharSequence charSequence) {
-<span class="fc bfc" id="L1430" title="All 2 branches covered."> if
(charSequence instanceof String) {</span>
-<span class="fc" id="L1431"> return ((String)
charSequence).trim();</span>
+<span class="fc bfc" id="L1441" title="All 2 branches covered."> if
(charSequence instanceof String) {</span>
+<span class="fc" id="L1442"> return ((String)
charSequence).trim();</span>
}
-<span class="fc" id="L1433"> final int count =
charSequence.length();</span>
-<span class="fc" id="L1434"> int len = count;</span>
-<span class="fc" id="L1435"> int pos = 0;</span>
+<span class="fc" id="L1444"> final int count =
charSequence.length();</span>
+<span class="fc" id="L1445"> int len = count;</span>
+<span class="fc" id="L1446"> int pos = 0;</span>
-<span class="fc bfc" id="L1437" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, pos)) {</span>
-<span class="fc" id="L1438"> pos++;</span>
+<span class="fc bfc" id="L1448" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, pos)) {</span>
+<span class="fc" id="L1449"> pos++;</span>
}
-<span class="fc bfc" id="L1440" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, len - 1)) {</span>
-<span class="fc" id="L1441"> len--;</span>
+<span class="fc bfc" id="L1451" title="All 4 branches covered."> while
(pos < len && isTrimChar(charSequence, len - 1)) {</span>
+<span class="fc" id="L1452"> len--;</span>
}
-<span class="fc bfc" id="L1443" title="All 4 branches covered."> return
pos > 0 || len < count ? charSequence.subSequence(pos, len) :
charSequence;</span>
+<span class="fc bfc" id="L1454" title="All 4 branches covered."> return
pos > 0 || len < count ? charSequence.subSequence(pos, len) :
charSequence;</span>
}
/**
@@ -1451,18 +1462,22 @@ public final class CSVFormat implements
* @since 1.2
*/
public static CSVFormat valueOf(final String format) {
-<span class="fc" id="L1454"> return
CSVFormat.Predefined.valueOf(format).getFormat();</span>
+<span class="fc" id="L1465"> return
CSVFormat.Predefined.valueOf(format).getFormat();</span>
}
+ /** How duplicate headers are handled. */
private final DuplicateHeaderMode duplicateHeaderMode;
+ /** Whether missing column names are allowed when parsing the header line.
*/
private final boolean allowMissingColumnNames;
+ /** Whether to flush on close. */
private final boolean autoFlush;
/** Set to null if commenting is disabled. */
private final Character commentMarker;
+ /** The character delimiting the values (typically ";",
"," or "\t"). */
private final String delimiter;
/** Set to null if escaping is disabled. */
@@ -1474,12 +1489,13 @@ public final class CSVFormat implements
/** Array of header comment lines. */
private final String[] headerComments;
+ /** Whether empty lines between records are ignored when parsing input. */
private final boolean ignoreEmptyLines;
/** Should ignore header names case. */
private final boolean ignoreHeaderCase;
- /** TODO Should leading/trailing spaces be ignored around values?. */
+ /** Should leading/trailing spaces be ignored around values?. */
private final boolean ignoreSurroundingSpaces;
/** The string to be used for null values. */
@@ -1488,47 +1504,54 @@ public final class CSVFormat implements
/** Set to null if quoting is disabled. */
private final Character quoteCharacter;
+ /** Set to {@code quoteCharacter + nullString + quoteCharacter} */
private final String quotedNullString;
+ /** The quote policy output fields. */
private final QuoteMode quoteMode;
/** For output. */
private final String recordSeparator;
+ /** Whether to skip the header record. */
private final boolean skipHeaderRecord;
+ /** Whether reading end-of-file is allowed even when input is malformed,
helps Excel compatibility. */
private final boolean lenientEof;
+ /** Whether reading trailing data is allowed in records, helps Excel
compatibility. */
private final boolean trailingData;
+ /** Whether to add a trailing delimiter. */
private final boolean trailingDelimiter;
+ /** Whether to trim leading and trailing blanks. */
private final boolean trim;
-<span class="fc" id="L1508"> private CSVFormat(final Builder builder)
{</span>
-<span class="fc" id="L1509"> this.delimiter = builder.delimiter;</span>
-<span class="fc" id="L1510"> this.quoteCharacter =
builder.quoteCharacter;</span>
-<span class="fc" id="L1511"> this.quoteMode = builder.quoteMode;</span>
-<span class="fc" id="L1512"> this.commentMarker =
builder.commentMarker;</span>
-<span class="fc" id="L1513"> this.escapeCharacter =
builder.escapeCharacter;</span>
-<span class="fc" id="L1514"> this.ignoreSurroundingSpaces =
builder.ignoreSurroundingSpaces;</span>
-<span class="fc" id="L1515"> this.allowMissingColumnNames =
builder.allowMissingColumnNames;</span>
-<span class="fc" id="L1516"> this.ignoreEmptyLines =
builder.ignoreEmptyLines;</span>
-<span class="fc" id="L1517"> this.recordSeparator =
builder.recordSeparator;</span>
-<span class="fc" id="L1518"> this.nullString =
builder.nullString;</span>
-<span class="fc" id="L1519"> this.headerComments =
builder.headerComments;</span>
-<span class="fc" id="L1520"> this.headers = builder.headers;</span>
-<span class="fc" id="L1521"> this.skipHeaderRecord =
builder.skipHeaderRecord;</span>
-<span class="fc" id="L1522"> this.ignoreHeaderCase =
builder.ignoreHeaderCase;</span>
-<span class="fc" id="L1523"> this.lenientEof =
builder.lenientEof;</span>
-<span class="fc" id="L1524"> this.trailingData =
builder.trailingData;</span>
-<span class="fc" id="L1525"> this.trailingDelimiter =
builder.trailingDelimiter;</span>
-<span class="fc" id="L1526"> this.trim = builder.trim;</span>
-<span class="fc" id="L1527"> this.autoFlush = builder.autoFlush;</span>
-<span class="fc" id="L1528"> this.quotedNullString =
builder.quotedNullString;</span>
-<span class="fc" id="L1529"> this.duplicateHeaderMode =
builder.duplicateHeaderMode;</span>
-<span class="fc" id="L1530"> validate();</span>
-<span class="fc" id="L1531"> }</span>
+<span class="fc" id="L1531"> private CSVFormat(final Builder builder)
{</span>
+<span class="fc" id="L1532"> this.delimiter = builder.delimiter;</span>
+<span class="fc" id="L1533"> this.quoteCharacter =
builder.quoteCharacter;</span>
+<span class="fc" id="L1534"> this.quoteMode = builder.quoteMode;</span>
+<span class="fc" id="L1535"> this.commentMarker =
builder.commentMarker;</span>
+<span class="fc" id="L1536"> this.escapeCharacter =
builder.escapeCharacter;</span>
+<span class="fc" id="L1537"> this.ignoreSurroundingSpaces =
builder.ignoreSurroundingSpaces;</span>
+<span class="fc" id="L1538"> this.allowMissingColumnNames =
builder.allowMissingColumnNames;</span>
+<span class="fc" id="L1539"> this.ignoreEmptyLines =
builder.ignoreEmptyLines;</span>
+<span class="fc" id="L1540"> this.recordSeparator =
builder.recordSeparator;</span>
+<span class="fc" id="L1541"> this.nullString =
builder.nullString;</span>
+<span class="fc" id="L1542"> this.headerComments =
builder.headerComments;</span>
+<span class="fc" id="L1543"> this.headers = builder.headers;</span>
+<span class="fc" id="L1544"> this.skipHeaderRecord =
builder.skipHeaderRecord;</span>
+<span class="fc" id="L1545"> this.ignoreHeaderCase =
builder.ignoreHeaderCase;</span>
+<span class="fc" id="L1546"> this.lenientEof =
builder.lenientEof;</span>
+<span class="fc" id="L1547"> this.trailingData =
builder.trailingData;</span>
+<span class="fc" id="L1548"> this.trailingDelimiter =
builder.trailingDelimiter;</span>
+<span class="fc" id="L1549"> this.trim = builder.trim;</span>
+<span class="fc" id="L1550"> this.autoFlush = builder.autoFlush;</span>
+<span class="fc" id="L1551"> this.quotedNullString =
builder.quotedNullString;</span>
+<span class="fc" id="L1552"> this.duplicateHeaderMode =
builder.duplicateHeaderMode;</span>
+<span class="fc" id="L1553"> validate();</span>
+<span class="fc" id="L1554"> }</span>
/**
* Creates a customized CSV format.
@@ -1541,14 +1564,14 @@ public final class CSVFormat implements
* @param ignoreSurroundingSpaces {@code true} when whitespaces enclosing
values should be ignored.
* @param ignoreEmptyLines {@code true} when the parser should skip
empty lines.
* @param recordSeparator the line separator to use for output.
- * @param nullString the line separator to use for output.
- * @param headerComments the comments to be printed by the
Printer before the actual CSV data..
+ * @param nullString the String to convert to and from {@code
null}.
+ * @param headerComments the comments to be printed by the
Printer before the actual CSV data.
* @param header the header.
* @param skipHeaderRecord if {@code true} the header row will be
skipped.
* @param allowMissingColumnNames if {@code true} the missing column names
are allowed when parsing the header line.
* @param ignoreHeaderCase if {@code true} header names will be
accessed ignoring case when parsing input.
* @param trim if {@code true} next record value will
be trimmed.
- * @param trailingDelimiter if {@code true} the trailing delimiter
wil be added before record separator (if set)..
+ * @param trailingDelimiter if {@code true} the trailing delimiter
wil be added before record separator (if set).
* @param autoFlush if {@code true} the underlying stream
will be flushed before closing.
* @param duplicateHeaderMode the behavior when handling duplicate
headers.
* @param trailingData whether reading trailing data is allowed
in records, helps Excel compatibility.
@@ -1559,46 +1582,46 @@ public final class CSVFormat implements
final boolean ignoreSurroundingSpaces, final boolean
ignoreEmptyLines, final String recordSeparator, final String nullString,
final Object[] headerComments, final String[] header, final
boolean skipHeaderRecord, final boolean allowMissingColumnNames,
final boolean ignoreHeaderCase, final boolean trim, final boolean
trailingDelimiter, final boolean autoFlush,
-<span class="fc" id="L1562"> final DuplicateHeaderMode
duplicateHeaderMode, final boolean trailingData, final boolean lenientEof)
{</span>
-<span class="fc" id="L1563"> this.delimiter = delimiter;</span>
-<span class="fc" id="L1564"> this.quoteCharacter = quoteChar;</span>
-<span class="fc" id="L1565"> this.quoteMode = quoteMode;</span>
-<span class="fc" id="L1566"> this.commentMarker = commentStart;</span>
-<span class="fc" id="L1567"> this.escapeCharacter = escape;</span>
-<span class="fc" id="L1568"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
-<span class="fc" id="L1569"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
-<span class="fc" id="L1570"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
-<span class="fc" id="L1571"> this.recordSeparator =
recordSeparator;</span>
-<span class="fc" id="L1572"> this.nullString = nullString;</span>
-<span class="fc" id="L1573"> this.headerComments =
toStringArray(headerComments);</span>
-<span class="fc" id="L1574"> this.headers = clone(header);</span>
-<span class="fc" id="L1575"> this.skipHeaderRecord =
skipHeaderRecord;</span>
-<span class="fc" id="L1576"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
-<span class="fc" id="L1577"> this.lenientEof = lenientEof;</span>
-<span class="fc" id="L1578"> this.trailingData = trailingData;</span>
-<span class="fc" id="L1579"> this.trailingDelimiter =
trailingDelimiter;</span>
-<span class="fc" id="L1580"> this.trim = trim;</span>
-<span class="fc" id="L1581"> this.autoFlush = autoFlush;</span>
-<span class="fc" id="L1582"> this.quotedNullString = quoteCharacter +
nullString + quoteCharacter;</span>
-<span class="fc" id="L1583"> this.duplicateHeaderMode =
duplicateHeaderMode;</span>
-<span class="fc" id="L1584"> validate();</span>
-<span class="fc" id="L1585"> }</span>
+<span class="fc" id="L1585"> final DuplicateHeaderMode
duplicateHeaderMode, final boolean trailingData, final boolean lenientEof)
{</span>
+<span class="fc" id="L1586"> this.delimiter = delimiter;</span>
+<span class="fc" id="L1587"> this.quoteCharacter = quoteChar;</span>
+<span class="fc" id="L1588"> this.quoteMode = quoteMode;</span>
+<span class="fc" id="L1589"> this.commentMarker = commentStart;</span>
+<span class="fc" id="L1590"> this.escapeCharacter = escape;</span>
+<span class="fc" id="L1591"> this.ignoreSurroundingSpaces =
ignoreSurroundingSpaces;</span>
+<span class="fc" id="L1592"> this.allowMissingColumnNames =
allowMissingColumnNames;</span>
+<span class="fc" id="L1593"> this.ignoreEmptyLines =
ignoreEmptyLines;</span>
+<span class="fc" id="L1594"> this.recordSeparator =
recordSeparator;</span>
+<span class="fc" id="L1595"> this.nullString = nullString;</span>
+<span class="fc" id="L1596"> this.headerComments =
toStringArray(headerComments);</span>
+<span class="fc" id="L1597"> this.headers = clone(header);</span>
+<span class="fc" id="L1598"> this.skipHeaderRecord =
skipHeaderRecord;</span>
+<span class="fc" id="L1599"> this.ignoreHeaderCase =
ignoreHeaderCase;</span>
+<span class="fc" id="L1600"> this.lenientEof = lenientEof;</span>
+<span class="fc" id="L1601"> this.trailingData = trailingData;</span>
+<span class="fc" id="L1602"> this.trailingDelimiter =
trailingDelimiter;</span>
+<span class="fc" id="L1603"> this.trim = trim;</span>
+<span class="fc" id="L1604"> this.autoFlush = autoFlush;</span>
+<span class="fc" id="L1605"> this.quotedNullString = quoteCharacter +
nullString + quoteCharacter;</span>
+<span class="fc" id="L1606"> this.duplicateHeaderMode =
duplicateHeaderMode;</span>
+<span class="fc" id="L1607"> validate();</span>
+<span class="fc" id="L1608"> }</span>
private void append(final char c, final Appendable appendable) throws
IOException {
//try {
-<span class="fc" id="L1589"> appendable.append(c);</span>
+<span class="fc" id="L1612"> appendable.append(c);</span>
//} catch (final IOException e) {
// throw new UncheckedIOException(e);
//}
-<span class="fc" id="L1593"> }</span>
+<span class="fc" id="L1616"> }</span>
private void append(final CharSequence csq, final Appendable appendable)
throws IOException {
//try {
-<span class="fc" id="L1597"> appendable.append(csq);</span>
+<span class="fc" id="L1620"> appendable.append(csq);</span>
//} catch (final IOException e) {
// throw new UncheckedIOException(e);
//}
-<span class="fc" id="L1601"> }</span>
+<span class="fc" id="L1624"> }</span>
/**
* Creates a new Builder for this instance.
@@ -1606,7 +1629,7 @@ public final class CSVFormat implements
* @return a new Builder.
*/
public Builder builder() {
-<span class="fc" id="L1609"> return Builder.create(this);</span>
+<span class="fc" id="L1632"> return Builder.create(this);</span>
}
/**
@@ -1615,37 +1638,37 @@ public final class CSVFormat implements
* @return a copy of this instance.
*/
CSVFormat copy() {
-<span class="fc" id="L1618"> return builder().build();</span>
+<span class="fc" id="L1641"> return builder().build();</span>
}
@Override
public boolean equals(final Object obj) {
-<span class="fc bfc" id="L1623" title="All 2 branches covered."> if
(this == obj) {</span>
-<span class="fc" id="L1624"> return true;</span>
+<span class="fc bfc" id="L1646" title="All 2 branches covered."> if
(this == obj) {</span>
+<span class="fc" id="L1647"> return true;</span>
}
-<span class="pc bpc" id="L1626" title="1 of 2 branches missed."> if
(obj == null) {</span>
-<span class="nc" id="L1627"> return false;</span>
+<span class="pc bpc" id="L1649" title="1 of 2 branches missed."> if
(obj == null) {</span>
+<span class="nc" id="L1650"> return false;</span>
}
-<span class="pc bpc" id="L1629" title="1 of 2 branches missed."> if
(getClass() != obj.getClass()) {</span>
-<span class="nc" id="L1630"> return false;</span>
+<span class="pc bpc" id="L1652" title="1 of 2 branches missed."> if
(getClass() != obj.getClass()) {</span>
+<span class="nc" id="L1653"> return false;</span>
}
-<span class="fc" id="L1632"> final CSVFormat other = (CSVFormat)
obj;</span>
-<span class="fc bfc" id="L1633" title="All 4 branches covered."> return
allowMissingColumnNames == other.allowMissingColumnNames && autoFlush
== other.autoFlush &&</span>
-<span class="fc bfc" id="L1634" title="All 6 branches covered.">
Objects.equals(commentMarker, other.commentMarker) &&
Objects.equals(delimiter, other.delimiter) &&</span>
-<span class="fc bfc" id="L1635" title="All 2 branches covered.">
duplicateHeaderMode == other.duplicateHeaderMode &&
Objects.equals(escapeCharacter, other.escapeCharacter) &&</span>
-<span class="pc bpc" id="L1636" title="1 of 12 branches missed.">
Arrays.equals(headerComments, other.headerComments) &&
Arrays.equals(headers, other.headers) &&</span>
+<span class="fc" id="L1655"> final CSVFormat other = (CSVFormat)
obj;</span>
+<span class="fc bfc" id="L1656" title="All 4 branches covered."> return
allowMissingColumnNames == other.allowMissingColumnNames && autoFlush
== other.autoFlush &&</span>
+<span class="fc bfc" id="L1657" title="All 6 branches covered.">
Objects.equals(commentMarker, other.commentMarker) &&
Objects.equals(delimiter, other.delimiter) &&</span>
+<span class="fc bfc" id="L1658" title="All 2 branches covered.">
duplicateHeaderMode == other.duplicateHeaderMode &&
Objects.equals(escapeCharacter, other.escapeCharacter) &&</span>
+<span class="pc bpc" id="L1659" 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="L1639" title="All 6 branches covered.">
Objects.equals(nullString, other.nullString) &&
Objects.equals(quoteCharacter, other.quoteCharacter) &&</span>
-<span class="pc bpc" id="L1640" title="1 of 2 branches missed.">
quoteMode == other.quoteMode && Objects.equals(quotedNullString,
other.quotedNullString) &&</span>
-<span class="pc bpc" id="L1641" title="1 of 10 branches missed.">
Objects.equals(recordSeparator, other.recordSeparator) &&
skipHeaderRecord == other.skipHeaderRecord &&</span>
+<span class="fc bfc" id="L1662" title="All 6 branches covered.">
Objects.equals(nullString, other.nullString) &&
Objects.equals(quoteCharacter, other.quoteCharacter) &&</span>
+<span class="pc bpc" id="L1663" title="1 of 2 branches missed.">
quoteMode == other.quoteMode && Objects.equals(quotedNullString,
other.quotedNullString) &&</span>
+<span class="pc bpc" id="L1664" 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="L1646"> append(escapeCharacter.charValue(),
appendable);</span>
-<span class="fc" id="L1647"> append(c, appendable);</span>
-<span class="fc" id="L1648"> }</span>
+<span class="fc" id="L1669"> append(escapeCharacter.charValue(),
appendable); // N.B. Explicit (un)boxing is intentional</span>
+<span class="fc" id="L1670"> append(c, appendable);</span>
+<span class="fc" id="L1671"> }</span>
/**
* Formats the specified values.
@@ -1654,16 +1677,16 @@ public final class CSVFormat implements
* @return the formatted values
*/
public String format(final Object... values) {
-<span class="fc" id="L1657"> return Uncheck.get(() ->
format_(values));</span>
+<span class="fc" id="L1680"> return Uncheck.get(() ->
format_(values));</span>
}
private String format_(final Object... values) throws IOException {
-<span class="fc" id="L1661"> final StringWriter out = new
StringWriter();</span>
-<span class="fc" id="L1662"> try (CSVPrinter csvPrinter = new
CSVPrinter(out, this)) {</span>
-<span class="fc" id="L1663"> csvPrinter.printRecord(values);</span>
-<span class="fc" id="L1664"> final String res =
out.toString();</span>
-<span class="fc bfc" id="L1665" title="All 2 branches covered.">
final int len = recordSeparator != null ? res.length() -
recordSeparator.length() : res.length();</span>
-<span class="fc" id="L1666"> return res.substring(0, len);</span>
+<span class="fc" id="L1684"> final StringWriter out = new
StringWriter();</span>
+<span class="fc" id="L1685"> try (CSVPrinter csvPrinter = new
CSVPrinter(out, this)) {</span>
+<span class="fc" id="L1686"> csvPrinter.printRecord(values);</span>
+<span class="fc" id="L1687"> final String res =
out.toString();</span>
+<span class="fc bfc" id="L1688" title="All 2 branches covered.">
final int len = recordSeparator != null ? res.length() -
recordSeparator.length() : res.length();</span>
+<span class="fc" id="L1689"> return res.substring(0, len);</span>
}
}
@@ -1676,7 +1699,7 @@ public final class CSVFormat implements
*/
@Deprecated
public boolean getAllowDuplicateHeaderNames() {
-<span class="fc bfc" id="L1679" title="All 2 branches covered."> return
duplicateHeaderMode == DuplicateHeaderMode.ALLOW_ALL;</span>
+<span class="fc bfc" id="L1702" title="All 2 branches covered."> return
duplicateHeaderMode == DuplicateHeaderMode.ALLOW_ALL;</span>
}
/**
@@ -1685,7 +1708,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="L1688"> return allowMissingColumnNames;</span>
+<span class="fc" id="L1711"> return allowMissingColumnNames;</span>
}
/**
@@ -1695,7 +1718,7 @@ public final class CSVFormat implements
* @since 1.6
*/
public boolean getAutoFlush() {
-<span class="fc" id="L1698"> return autoFlush;</span>
+<span class="fc" id="L1721"> return autoFlush;</span>
}
/**
@@ -1731,7 +1754,7 @@ public final class CSVFormat implements
* @return the comment start marker, may be {@code null}
*/
public Character getCommentMarker() {
-<span class="fc" id="L1734"> return commentMarker;</span>
+<span class="fc" id="L1757"> return commentMarker;</span>
}
/**
@@ -1742,7 +1765,7 @@ public final class CSVFormat implements
*/
@Deprecated
public char getDelimiter() {
-<span class="fc" id="L1745"> return delimiter.charAt(0);</span>
+<span class="fc" id="L1768"> return delimiter.charAt(0);</span>
}
/**
@@ -1751,7 +1774,7 @@ public final class CSVFormat implements
* @return the delimiter.
*/
char[] getDelimiterCharArray() {
-<span class="fc" id="L1754"> return delimiter.toCharArray();</span>
+<span class="fc" id="L1777"> return delimiter.toCharArray();</span>
}
/**
@@ -1761,7 +1784,7 @@ public final class CSVFormat implements
* @since 1.9.0
*/
public String getDelimiterString() {
-<span class="fc" id="L1764"> return delimiter;</span>
+<span class="fc" id="L1787"> return delimiter;</span>
}
/**
@@ -1771,7 +1794,7 @@ public final class CSVFormat implements
* @since 1.10.0
*/
public DuplicateHeaderMode getDuplicateHeaderMode() {
-<span class="fc" id="L1774"> return duplicateHeaderMode;</span>
+<span class="fc" id="L1797"> return duplicateHeaderMode;</span>
}
/**
@@ -1780,7 +1803,7 @@ public final class CSVFormat implements
* @return the escape character, may be {@code 0}
*/
char getEscapeChar() {
-<span class="pc bpc" id="L1783" title="1 of 2 branches missed."> return
escapeCharacter != null ? escapeCharacter.charValue() : 0;</span>
+<span class="pc bpc" id="L1806" title="1 of 2 branches missed."> return
escapeCharacter != null ? escapeCharacter.charValue() : 0; // N.B. Explicit
(un)boxing is intentional</span>
}
/**
@@ -1789,7 +1812,7 @@ public final class CSVFormat implements
* @return the escape character, may be {@code null}
*/
public Character getEscapeCharacter() {
-<span class="fc" id="L1792"> return escapeCharacter;</span>
+<span class="fc" id="L1815"> return escapeCharacter;</span>
}
/**
@@ -1798,7 +1821,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="L1801" title="All 2 branches covered."> return
headers != null ? headers.clone() : null;</span>
+<span class="fc bfc" id="L1824" title="All 2 branches covered."> return
headers != null ? headers.clone() : null;</span>
}
/**
@@ -1834,7 +1857,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="L1837" title="All 2 branches covered."> return
headerComments != null ? headerComments.clone() : null;</span>
+<span class="fc bfc" id="L1860" title="All 2 branches covered."> return
headerComments != null ? headerComments.clone() : null;</span>
}
/**
@@ -1843,7 +1866,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="L1846"> return ignoreEmptyLines;</span>
+<span class="fc" id="L1869"> return ignoreEmptyLines;</span>
}
/**
@@ -1853,7 +1876,7 @@ public final class CSVFormat implements
* @since 1.3
*/
public boolean getIgnoreHeaderCase() {
-<span class="fc" id="L1856"> return ignoreHeaderCase;</span>
+<span class="fc" id="L1879"> return ignoreHeaderCase;</span>
}
/**
@@ -1862,7 +1885,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="L1865"> return ignoreSurroundingSpaces;</span>
+<span class="fc" id="L1888"> return ignoreSurroundingSpaces;</span>
}
/**
@@ -1872,7 +1895,7 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public boolean getLenientEof() {
-<span class="fc" id="L1875"> return lenientEof;</span>
+<span class="fc" id="L1898"> return lenientEof;</span>
}
/**
@@ -1885,7 +1908,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="L1888"> return nullString;</span>
+<span class="fc" id="L1911"> return nullString;</span>
}
/**
@@ -1894,7 +1917,7 @@ public final class CSVFormat implements
* @return the quoteChar character, may be {@code null}
*/
public Character getQuoteCharacter() {
-<span class="fc" id="L1897"> return quoteCharacter;</span>
+<span class="fc" id="L1920"> return quoteCharacter;</span>
}
/**
@@ -1903,7 +1926,7 @@ public final class CSVFormat implements
* @return the quote policy
*/
public QuoteMode getQuoteMode() {
-<span class="fc" id="L1906"> return quoteMode;</span>
+<span class="fc" id="L1929"> return quoteMode;</span>
}
/**
@@ -1912,7 +1935,7 @@ public final class CSVFormat implements
* @return the record separator
*/
public String getRecordSeparator() {
-<span class="fc" id="L1915"> return recordSeparator;</span>
+<span class="fc" id="L1938"> return recordSeparator;</span>
}
/**
@@ -1921,7 +1944,7 @@ public final class CSVFormat implements
* @return whether to skip the header record.
*/
public boolean getSkipHeaderRecord() {
-<span class="fc" id="L1924"> return skipHeaderRecord;</span>
+<span class="fc" id="L1947"> return skipHeaderRecord;</span>
}
/**
@@ -1931,7 +1954,7 @@ public final class CSVFormat implements
* @since 1.11.0
*/
public boolean getTrailingData() {
-<span class="fc" id="L1934"> return trailingData;</span>
+<span class="fc" id="L1957"> return trailingData;</span>
}
/**
@@ -1941,7 +1964,7 @@ public final class CSVFormat implements
* @since 1.3
*/
public boolean getTrailingDelimiter() {
-<span class="fc" id="L1944"> return trailingDelimiter;</span>
+<span class="fc" id="L1967"> return trailingDelimiter;</span>
}
/**
@@ -1951,19 +1974,19 @@ public final class CSVFormat implements
* @return whether to trim leading and trailing blanks.
*/
public boolean getTrim() {
-<span class="fc" id="L1954"> return trim;</span>
+<span class="fc" id="L1977"> return trim;</span>
}
@Override
public int hashCode() {
-<span class="fc" id="L1959"> final int prime = 31;</span>
-<span class="fc" id="L1960"> int result = 1;</span>
-<span class="fc" id="L1961"> result = prime * result +
Arrays.hashCode(headerComments);</span>
-<span class="fc" id="L1962"> result = prime * result +
Arrays.hashCode(headers);</span>
-<span class="fc" id="L1963"> result = prime * result +
Objects.hash(allowMissingColumnNames, autoFlush, commentMarker, delimiter,
duplicateHeaderMode, escapeCharacter,</span>
-<span class="fc" id="L1964"> ignoreEmptyLines,
ignoreHeaderCase, ignoreSurroundingSpaces, lenientEof, nullString,
quoteCharacter, quoteMode, quotedNullString,</span>
-<span class="fc" id="L1965"> recordSeparator, skipHeaderRecord,
trailingData, trailingDelimiter, trim);</span>
-<span class="fc" id="L1966"> return result;</span>
+<span class="fc" id="L1982"> final int prime = 31;</span>
+<span class="fc" id="L1983"> int result = 1;</span>
+<span class="fc" id="L1984"> result = prime * result +
Arrays.hashCode(headerComments);</span>
+<span class="fc" id="L1985"> result = prime * result +
Arrays.hashCode(headers);</span>
+<span class="fc" id="L1986"> result = prime * result +
Objects.hash(allowMissingColumnNames, autoFlush, commentMarker, delimiter,
duplicateHeaderMode, escapeCharacter,</span>
+<span class="fc" id="L1987"> ignoreEmptyLines,
ignoreHeaderCase, ignoreSurroundingSpaces, lenientEof, nullString,
quoteCharacter, quoteMode, quotedNullString,</span>
+<span class="fc" id="L1988"> recordSeparator, skipHeaderRecord,
trailingData, trailingDelimiter, trim);</span>
+<span class="fc" id="L1989"> return result;</span>
}
/**
@@ -1974,7 +1997,7 @@ public final class CSVFormat implements
* @return {@code true} is comments are supported, {@code false} otherwise
*/
public boolean isCommentMarkerSet() {
-<span class="fc bfc" id="L1977" title="All 2 branches covered."> return
commentMarker != null;</span>
+<span class="fc bfc" id="L2000" title="All 2 branches covered."> return
commentMarker != null;</span>
}
/**
@@ -1993,19 +2016,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="L1996" title="All 2 branches covered."> if
(ch0 != delimiter[0]) {</span>
-<span class="fc" id="L1997"> return false;</span>
+<span class="fc bfc" id="L2019" title="All 2 branches covered."> if
(ch0 != delimiter[0]) {</span>
+<span class="fc" id="L2020"> return false;</span>
}
-<span class="fc" id="L1999"> final int len = charSeq.length();</span>
-<span class="fc bfc" id="L2000" title="All 2 branches covered."> if
(startIndex + delimiterLength > len) {</span>
-<span class="fc" id="L2001"> return false;</span>
- }
-<span class="fc bfc" id="L2003" title="All 2 branches covered."> for
(int i = 1; i < delimiterLength; i++) {</span>
-<span class="fc bfc" id="L2004" title="All 2 branches covered."> if
(charSeq.charAt(startIndex + i) != delimiter[i]) {</span>
-<span class="fc" id="L2005"> return false;</span>
+<span class="fc" id="L2022"> final int len = charSeq.length();</span>
+<span class="fc bfc" id="L2023" title="All 2 branches covered."> if
(startIndex + delimiterLength > len) {</span>
+<span class="fc" id="L2024"> return false;</span>
+ }
+<span class="fc bfc" id="L2026" title="All 2 branches covered."> for
(int i = 1; i < delimiterLength; i++) {</span>
+<span class="fc bfc" id="L2027" title="All 2 branches covered."> if
(charSeq.charAt(startIndex + i) != delimiter[i]) {</span>
+<span class="fc" id="L2028"> return false;</span>
}
}
-<span class="fc" id="L2008"> return true;</span>
+<span class="fc" id="L2031"> return true;</span>
}
/**
@@ -2014,7 +2037,7 @@ public final class CSVFormat implements
* @return {@code true} if escapes are processed
*/
public boolean isEscapeCharacterSet() {
-<span class="fc bfc" id="L2017" title="All 2 branches covered."> return
escapeCharacter != null;</span>
+<span class="fc bfc" id="L2040" title="All 2 branches covered."> return
escapeCharacter != null;</span>
}
[... 1109 lines stripped ...]