You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/03/11 13:29:47 UTC
(commons-csv) branch master updated (094d0e7d -> 5e5e28c5)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
from 094d0e7d Update changes.xml
new fc2f1b5a Whitespace
new 1eb95dc4 Whitespace
new 5e5e28c5 Internal refactoring
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/commons/csv/CSVFormat.java | 43 +++-------------------
.../java/org/apache/commons/csv/Constants.java | 5 +--
.../apache/commons/csv/ExtendedBufferedReader.java | 20 +++++-----
src/main/java/org/apache/commons/csv/Lexer.java | 31 ++++++++--------
.../commons/csv/ExtendedBufferedReaderTest.java | 22 +++++------
.../org/apache/commons/csv/PerformanceTest.java | 6 ++-
6 files changed, 46 insertions(+), 81 deletions(-)
(commons-csv) 02/03: Whitespace
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
commit 1eb95dc4d991641d707e84a43750f6097a442d2e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 11 08:55:04 2024 -0400
Whitespace
(commons-csv) 03/03: Internal refactoring
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
commit 5e5e28c55189da018b2ecc5346b364e2f07b32f2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 11 09:29:41 2024 -0400
Internal refactoring
Reduce whitepace
---
.../java/org/apache/commons/csv/CSVFormat.java | 9 ++++---
.../java/org/apache/commons/csv/Constants.java | 5 +---
.../apache/commons/csv/ExtendedBufferedReader.java | 20 +++++++-------
src/main/java/org/apache/commons/csv/Lexer.java | 31 +++++++++++-----------
.../commons/csv/ExtendedBufferedReaderTest.java | 22 +++++++--------
.../org/apache/commons/csv/PerformanceTest.java | 6 +++--
6 files changed, 46 insertions(+), 47 deletions(-)
diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java
index fae274e1..6b203a6d 100644
--- a/src/main/java/org/apache/commons/csv/CSVFormat.java
+++ b/src/main/java/org/apache/commons/csv/CSVFormat.java
@@ -28,6 +28,7 @@ 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;
@@ -2172,7 +2173,7 @@ public final class CSVFormat implements Serializable {
final char escape = getEscapeCharacter().charValue();
final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
int c;
- while (-1 != (c = bufferedReader.read())) {
+ while (EOF != (c = bufferedReader.read())) {
builder.append((char) c);
final boolean isDelimiterStart = isDelimiter((char) c, builder.toString() + new String(bufferedReader.lookAhead(delimLength - 1)), pos, delim,
delimLength);
@@ -2321,12 +2322,12 @@ public final class CSVFormat implements Serializable {
printWithEscapes(reader, appendable);
return;
}
- int pos = 0;
final char quote = getQuoteCharacter().charValue();
- final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
append(quote, appendable);
+ final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
int c;
- while (-1 != (c = reader.read())) {
+ int pos = 0;
+ while (EOF != (c = reader.read())) {
builder.append((char) c);
if (c == quote) {
// write out segment up until this char
diff --git a/src/main/java/org/apache/commons/csv/Constants.java b/src/main/java/org/apache/commons/csv/Constants.java
index 9b9e2d41..15c5ef6f 100644
--- a/src/main/java/org/apache/commons/csv/Constants.java
+++ b/src/main/java/org/apache/commons/csv/Constants.java
@@ -18,7 +18,7 @@
package org.apache.commons.csv;
/**
- * Constants for this package.
+ * Private constants to this package.
*/
final class Constants {
@@ -44,9 +44,6 @@ final class Constants {
static final String[] EMPTY_STRING_ARRAY = {};
- /** The end of stream symbol */
- static final int END_OF_STREAM = -1;
-
static final char FF = '\f';
static final char LF = '\n';
diff --git a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
index 429b07cb..40c7c140 100644
--- a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
+++ b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
@@ -18,9 +18,9 @@
package org.apache.commons.csv;
import static org.apache.commons.csv.Constants.CR;
-import static org.apache.commons.csv.Constants.END_OF_STREAM;
import static org.apache.commons.csv.Constants.LF;
import static org.apache.commons.csv.Constants.UNDEFINED;
+import static org.apache.commons.io.IOUtils.EOF;
import java.io.BufferedReader;
import java.io.IOException;
@@ -63,7 +63,7 @@ final class ExtendedBufferedReader extends BufferedReader {
public void close() throws IOException {
// Set ivars before calling super close() in case close() throws an IOException.
closed = true;
- lastChar = END_OF_STREAM;
+ lastChar = EOF;
super.close();
}
@@ -74,7 +74,7 @@ final class ExtendedBufferedReader extends BufferedReader {
*/
long getCurrentLineNumber() {
// Check if we are at EOL or EOF or just starting
- if (lastChar == CR || lastChar == LF || lastChar == UNDEFINED || lastChar == END_OF_STREAM) {
+ if (lastChar == CR || lastChar == LF || lastChar == UNDEFINED || lastChar == EOF) {
return eolCounter; // counter is accurate
}
return eolCounter + 1; // Allow for counter being incremented only at EOL
@@ -84,7 +84,7 @@ final class ExtendedBufferedReader extends BufferedReader {
* Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by
* any of the read methods. This will not include a character read using the {@link #lookAhead()} method. If no
* character has been read then this will return {@link Constants#UNDEFINED}. If the end of the stream was reached
- * on the last read then this will return {@link Constants#END_OF_STREAM}.
+ * on the last read then this will return {@link Constants#EOF}.
*
* @return the last character that was read
*/
@@ -158,7 +158,7 @@ final class ExtendedBufferedReader extends BufferedReader {
public int read() throws IOException {
final int current = super.read();
if (current == CR || current == LF && lastChar != CR ||
- current == END_OF_STREAM && lastChar != CR && lastChar != LF && lastChar != END_OF_STREAM) {
+ current == EOF && lastChar != CR && lastChar != LF && lastChar != EOF) {
eolCounter++;
}
lastChar = current;
@@ -189,8 +189,8 @@ final class ExtendedBufferedReader extends BufferedReader {
lastChar = buf[offset + len - 1];
- } else if (len == -1) {
- lastChar = END_OF_STREAM;
+ } else if (len == EOF) {
+ lastChar = EOF;
}
position += len;
@@ -204,14 +204,14 @@ final class ExtendedBufferedReader extends BufferedReader {
* Increments {@link #eolCounter} and updates {@link #position}.
* </p>
* <p>
- * Sets {@link #lastChar} to {@link Constants#END_OF_STREAM} at EOF, otherwise the last EOL character.
+ * Sets {@link #lastChar} to {@link Constants#EOF} at EOF, otherwise the last EOL character.
* </p>
*
* @return the line that was read, or null if reached EOF.
*/
@Override
public String readLine() throws IOException {
- if (lookAhead() == END_OF_STREAM) {
+ if (lookAhead() == EOF) {
return null;
}
final StringBuilder buffer = new StringBuilder();
@@ -223,7 +223,7 @@ final class ExtendedBufferedReader extends BufferedReader {
read();
}
}
- if (current == END_OF_STREAM || current == LF || current == CR) {
+ if (current == EOF || current == LF || current == CR) {
break;
}
buffer.append((char) current);
diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java
index 2072c3ea..eeb39a64 100644
--- a/src/main/java/org/apache/commons/csv/Lexer.java
+++ b/src/main/java/org/apache/commons/csv/Lexer.java
@@ -19,16 +19,15 @@ package org.apache.commons.csv;
import static org.apache.commons.csv.Constants.BACKSPACE;
import static org.apache.commons.csv.Constants.CR;
-import static org.apache.commons.csv.Constants.END_OF_STREAM;
import static org.apache.commons.csv.Constants.FF;
import static org.apache.commons.csv.Constants.LF;
import static org.apache.commons.csv.Constants.TAB;
import static org.apache.commons.csv.Constants.UNDEFINED;
import static org.apache.commons.csv.Token.Type.COMMENT;
-import static org.apache.commons.csv.Token.Type.EOF;
import static org.apache.commons.csv.Token.Type.EORECORD;
import static org.apache.commons.csv.Token.Type.INVALID;
import static org.apache.commons.csv.Token.Type.TOKEN;
+import static org.apache.commons.io.IOUtils.EOF;
import java.io.Closeable;
import java.io.IOException;
@@ -141,7 +140,7 @@ final class Lexer implements Closeable {
}
}
final int count = reader.read(delimiterBuf, 0, delimiterBuf.length);
- isLastTokenDelimiter = count != END_OF_STREAM;
+ isLastTokenDelimiter = count != EOF;
return isLastTokenDelimiter;
}
@@ -151,7 +150,7 @@ final class Lexer implements Closeable {
* @return true if the given character indicates the end of the file.
*/
boolean isEndOfFile(final int ch) {
- return ch == END_OF_STREAM;
+ return ch == EOF;
}
/**
@@ -182,7 +181,7 @@ final class Lexer implements Closeable {
}
}
final int count = reader.read(escapeDelimiterBuf, 0, escapeDelimiterBuf.length);
- return count != END_OF_STREAM;
+ return count != EOF;
}
private boolean isMetaChar(final int ch) {
@@ -240,7 +239,7 @@ final class Lexer implements Closeable {
eol = readEndOfLine(c);
// reached the end of the file without any content (empty line at the end)
if (isEndOfFile(c)) {
- token.type = EOF;
+ token.type = Token.Type.EOF;
// don't set token.isReady here because no content
return token;
}
@@ -249,7 +248,7 @@ final class Lexer implements Closeable {
// Did we reach EOF during the last iteration already? EOF
if (isEndOfFile(lastChar) || !isLastTokenDelimiter && isEndOfFile(c)) {
- token.type = EOF;
+ token.type = Token.Type.EOF;
// don't set token.isReady here because no content
return token;
}
@@ -257,7 +256,7 @@ final class Lexer implements Closeable {
if (isStartOfLine(lastChar) && isCommentStart(c)) {
final String line = reader.readLine();
if (line == null) {
- token.type = EOF;
+ token.type = Token.Type.EOF;
// don't set token.isReady here because no content
return token;
}
@@ -291,7 +290,7 @@ final class Lexer implements Closeable {
} else if (isEndOfFile(c)) {
// end of file return EOF()
// noop: token.content.append("");
- token.type = EOF;
+ token.type = Token.Type.EOF;
token.isReady = true; // there is data at EOF
} else {
// next token must be a simple token
@@ -337,7 +336,7 @@ final class Lexer implements Closeable {
token.content.append(delimiter);
} else {
final int unescaped = readEscape();
- if (unescaped == END_OF_STREAM) { // unexpected char after escape
+ if (unescaped == EOF) { // unexpected char after escape
token.content.append((char) c).append((char) reader.getLastChar());
} else {
token.content.append((char) unescaped);
@@ -357,7 +356,7 @@ final class Lexer implements Closeable {
return token;
}
if (isEndOfFile(c)) {
- token.type = EOF;
+ token.type = Token.Type.EOF;
token.isReady = true; // There is data at EOF
return token;
}
@@ -411,7 +410,7 @@ final class Lexer implements Closeable {
break;
}
if (isEndOfFile(ch)) {
- token.type = EOF;
+ token.type = Token.Type.EOF;
token.isReady = true; // There is data at EOF
break;
}
@@ -425,7 +424,7 @@ final class Lexer implements Closeable {
token.content.append(delimiter);
} else {
final int unescaped = readEscape();
- if (unescaped == END_OF_STREAM) { // unexpected char after escape
+ if (unescaped == EOF) { // unexpected char after escape
token.content.append((char) ch).append((char) reader.getLastChar());
} else {
token.content.append((char) unescaped);
@@ -478,7 +477,7 @@ final class Lexer implements Closeable {
* On return, the next character is available by calling {@link ExtendedBufferedReader#getLastChar()}
* on the input stream.
*
- * @return the unescaped character (as an int) or {@link Constants#END_OF_STREAM} if char following the escape is
+ * @return the unescaped character (as an int) or {@link Constants#EOF} if char following the escape is
* invalid.
* @throws IOException if there is a problem reading the stream or the end of stream is detected:
* the escape character is not allowed at end of stream
@@ -503,7 +502,7 @@ final class Lexer implements Closeable {
case TAB: // TODO is this correct? Do tabs need to be escaped?
case BACKSPACE: // TODO is this correct?
return ch;
- case END_OF_STREAM:
+ case EOF:
throw new IOException("EOF whilst processing escape sequence");
default:
// Now check for meta-characters
@@ -511,7 +510,7 @@ final class Lexer implements Closeable {
return ch;
}
// indicate unexpected char - available from in.getLastChar()
- return END_OF_STREAM;
+ return EOF;
}
}
diff --git a/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java b/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
index 76f1568b..20c9dedd 100644
--- a/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
+++ b/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.csv;
-import static org.apache.commons.csv.Constants.END_OF_STREAM;
+import static org.apache.commons.io.IOUtils.EOF;
import static org.apache.commons.csv.Constants.UNDEFINED;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -39,9 +39,9 @@ public class ExtendedBufferedReaderTest {
@Test
public void testEmptyInput() throws Exception {
try (final ExtendedBufferedReader br = createBufferedReader("")) {
- assertEquals(END_OF_STREAM, br.read());
- assertEquals(END_OF_STREAM, br.lookAhead());
- assertEquals(END_OF_STREAM, br.getLastChar());
+ assertEquals(EOF, br.read());
+ assertEquals(EOF, br.lookAhead());
+ assertEquals(EOF, br.getLastChar());
assertNull(br.readLine());
assertEquals(0, br.read(new char[10], 0, 0));
}
@@ -69,7 +69,7 @@ public class ExtendedBufferedReaderTest {
}
try (final ExtendedBufferedReader br = createBufferedReader(test)) {
assertEquals(0, br.getCurrentLineNumber());
- while (br.read() != -1) {
+ while (br.read() != EOF) {
// consume all
}
assertEquals(EOLeolct, br.getCurrentLineNumber());
@@ -77,7 +77,7 @@ public class ExtendedBufferedReaderTest {
try (final ExtendedBufferedReader br = createBufferedReader(test)) {
assertEquals(0, br.getCurrentLineNumber());
final char[] buff = new char[10];
- while (br.read(buff, 0, 3) != -1) {
+ while (br.read(buff, 0, 3) != EOF) {
// consume all
}
assertEquals(EOLeolct, br.getCurrentLineNumber());
@@ -185,12 +185,12 @@ public class ExtendedBufferedReaderTest {
assertEquals('\n', br.getLastChar());
assertEquals(3, br.getCurrentLineNumber());
- assertEquals(END_OF_STREAM, br.lookAhead());
+ assertEquals(EOF, br.lookAhead());
assertEquals('\n', br.getLastChar());
- assertEquals(END_OF_STREAM, br.read());
- assertEquals(END_OF_STREAM, br.getLastChar());
- assertEquals(END_OF_STREAM, br.read());
- assertEquals(END_OF_STREAM, br.lookAhead());
+ assertEquals(EOF, br.read());
+ assertEquals(EOF, br.getLastChar());
+ assertEquals(EOF, br.read());
+ assertEquals(EOF, br.lookAhead());
assertEquals(3, br.getCurrentLineNumber());
}
diff --git a/src/test/java/org/apache/commons/csv/PerformanceTest.java b/src/test/java/org/apache/commons/csv/PerformanceTest.java
index 489d7235..3ef39588 100644
--- a/src/test/java/org/apache/commons/csv/PerformanceTest.java
+++ b/src/test/java/org/apache/commons/csv/PerformanceTest.java
@@ -17,6 +17,8 @@
package org.apache.commons.csv;
+import static org.apache.commons.io.IOUtils.EOF;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -258,7 +260,7 @@ public class PerformanceTest {
int read;
if (makeString) {
StringBuilder sb = new StringBuilder();
- while ((read = in.read()) != -1) {
+ while ((read = in.read()) != EOF) {
sb.append((char) read);
if (read == ',') { // count delimiters
sb.toString();
@@ -271,7 +273,7 @@ public class PerformanceTest {
}
}
} else {
- while ((read = in.read()) != -1) {
+ while ((read = in.read()) != EOF) {
if (read == ',') { // count delimiters
fields++;
} else if (read == '\n') {
(commons-csv) 01/03: Whitespace
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
commit fc2f1b5acafdb8eb1dc7bd970f864f5eaa78ef0e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 11 08:55:02 2024 -0400
Whitespace
---
.../java/org/apache/commons/csv/CSVFormat.java | 34 ----------------------
1 file changed, 34 deletions(-)
diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java
index 5cbee58a..fae274e1 100644
--- a/src/main/java/org/apache/commons/csv/CSVFormat.java
+++ b/src/main/java/org/apache/commons/csv/CSVFormat.java
@@ -2125,11 +2125,9 @@ public final class CSVFormat implements Serializable {
int start = 0;
int pos = 0;
final int end = charSeq.length();
-
final char[] delim = getDelimiterString().toCharArray();
final int delimLength = delim.length;
final char escape = getEscapeCharacter().charValue();
-
while (pos < end) {
char c = charSeq.charAt(pos);
final boolean isDelimiterStart = isDelimiter(c, charSeq, pos, delim, delimLength);
@@ -2143,10 +2141,8 @@ public final class CSVFormat implements Serializable {
} else if (c == CR) {
c = 'r';
}
-
appendable.append(escape);
appendable.append(c);
-
if (isDelimiterStart) {
for (int i = 1; i < delimLength; i++) {
pos++;
@@ -2155,7 +2151,6 @@ public final class CSVFormat implements Serializable {
appendable.append(c);
}
}
-
start = pos + 1; // start on the current char after this one
}
pos++;
@@ -2170,14 +2165,12 @@ public final class CSVFormat implements Serializable {
private void printWithEscapes(final Reader reader, final Appendable appendable) throws IOException {
int start = 0;
int pos = 0;
-
@SuppressWarnings("resource") // Temp reader on input reader.
final ExtendedBufferedReader bufferedReader = new ExtendedBufferedReader(reader);
final char[] delim = getDelimiterString().toCharArray();
final int delimLength = delim.length;
final char escape = getEscapeCharacter().charValue();
final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
-
int c;
while (-1 != (c = bufferedReader.read())) {
builder.append((char) c);
@@ -2195,10 +2188,8 @@ public final class CSVFormat implements Serializable {
} else if (c == CR) {
c = 'r';
}
-
append(escape, appendable);
append((char) c, appendable);
-
if (isDelimiterStart) {
for (int i = 1; i < delimLength; i++) {
c = bufferedReader.read();
@@ -2206,12 +2197,10 @@ public final class CSVFormat implements Serializable {
append((char) c, appendable);
}
}
-
start = pos + 1; // start on the current char after this one
}
pos++;
}
-
// write last segment
if (pos > start) {
append(builder.substring(start, pos), appendable);
@@ -2227,7 +2216,6 @@ public final class CSVFormat implements Serializable {
int start = 0;
int pos = 0;
final int len = charSeq.length();
-
final char[] delim = getDelimiterString().toCharArray();
final int delimLength = delim.length;
final char quoteChar = getQuoteCharacter().charValue();
@@ -2235,7 +2223,6 @@ public final class CSVFormat implements Serializable {
// This avoids having to keep checking whether there is an escape character
// at the cost of checking against quote twice
final char escapeChar = isEscapeCharacterSet() ? getEscapeCharacter().charValue() : quoteChar;
-
QuoteMode quoteModePolicy = getQuoteMode();
if (quoteModePolicy == null) {
quoteModePolicy = QuoteMode.MINIMAL;
@@ -2263,7 +2250,6 @@ public final class CSVFormat implements Serializable {
}
} else {
char c = charSeq.charAt(pos);
-
if (c <= COMMENT) {
// Some other chars at the start of a value caused the parser to fail, so for now
// encapsulate if we start in anything less than '#'. We are being conservative
@@ -2290,7 +2276,6 @@ public final class CSVFormat implements Serializable {
}
}
}
-
if (!quote) {
// No encapsulation needed - write out the original value
out.append(charSeq, start, len);
@@ -2300,16 +2285,13 @@ public final class CSVFormat implements Serializable {
default:
throw new IllegalStateException("Unexpected Quote value: " + quoteModePolicy);
}
-
if (!quote) {
// No encapsulation needed - write out the original value
out.append(charSeq, start, len);
return;
}
-
// We hit something that needed encapsulation
out.append(quoteChar);
-
// Pick up where we left off: pos should be positioned on the first character that caused
// the need for encapsulation.
while (pos < len) {
@@ -2322,7 +2304,6 @@ public final class CSVFormat implements Serializable {
}
pos++;
}
-
// Write the last segment
out.append(charSeq, start, pos);
out.append(quoteChar);
@@ -2336,19 +2317,14 @@ public final class CSVFormat implements Serializable {
* @throws IOException If an I/O error occurs
*/
private void printWithQuotes(final Reader reader, final Appendable appendable) throws IOException {
-
if (getQuoteMode() == QuoteMode.NONE) {
printWithEscapes(reader, appendable);
return;
}
-
int pos = 0;
-
final char quote = getQuoteCharacter().charValue();
final StringBuilder builder = new StringBuilder(IOUtils.DEFAULT_BUFFER_SIZE);
-
append(quote, appendable);
-
int c;
while (-1 != (c = reader.read())) {
builder.append((char) c);
@@ -2360,17 +2336,14 @@ public final class CSVFormat implements Serializable {
builder.setLength(0);
pos = -1;
}
-
append((char) c, appendable);
}
pos++;
}
-
// write last segment
if (pos > 0) {
append(builder.substring(0, pos), appendable);
}
-
append(quote, appendable);
}
@@ -2440,31 +2413,24 @@ public final class CSVFormat implements Serializable {
if (containsLineBreak(delimiter)) {
throw new IllegalArgumentException("The delimiter cannot be a line break");
}
-
if (quoteCharacter != null && contains(delimiter, quoteCharacter.charValue())) {
throw new IllegalArgumentException("The quoteChar character and the delimiter cannot be the same ('" + quoteCharacter + "')");
}
-
if (escapeCharacter != null && contains(delimiter, escapeCharacter.charValue())) {
throw new IllegalArgumentException("The escape character and the delimiter cannot be the same ('" + escapeCharacter + "')");
}
-
if (commentMarker != null && contains(delimiter, commentMarker.charValue())) {
throw new IllegalArgumentException("The comment start character and the delimiter cannot be the same ('" + commentMarker + "')");
}
-
if (quoteCharacter != null && quoteCharacter.equals(commentMarker)) {
throw new IllegalArgumentException("The comment start character and the quoteChar cannot be the same ('" + commentMarker + "')");
}
-
if (escapeCharacter != null && escapeCharacter.equals(commentMarker)) {
throw new IllegalArgumentException("The comment start and the escape character cannot be the same ('" + commentMarker + "')");
}
-
if (escapeCharacter == null && quoteMode == QuoteMode.NONE) {
throw new IllegalArgumentException("Quote mode set to NONE but no escape character is set");
}
-
// Validate headers
if (headers != null && duplicateHeaderMode != DuplicateHeaderMode.ALLOW_ALL) {
final Set<String> dupCheckSet = new HashSet<>(headers.length);