diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java
index cb8c03b5..4c3802d0 100644
--- a/src/main/java/org/apache/commons/csv/CSVFormat.java
+++ b/src/main/java/org/apache/commons/csv/CSVFormat.java
@@ -55,7 +55,7 @@ public class CSVFormat implements Serializable {
private final Character escape;
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
private final boolean ignoreEmptyLines;
- private final String lineSeparator; // for outputs
+ private final String recordSeparator; // for outputs
private final String[] header;
/**
@@ -77,7 +77,7 @@ public class CSVFormat implements Serializable {
.withDelimiter(COMMA)
.withQuoteChar(DOUBLE_QUOTE)
.withIgnoreEmptyLines(true)
- .withLineSeparator(CRLF);
+ .withRecordSeparator(CRLF);
/**
* Comma separated format as defined by RFC 4180.
@@ -92,7 +92,7 @@ public class CSVFormat implements Serializable {
PRISTINE
.withDelimiter(COMMA)
.withQuoteChar(DOUBLE_QUOTE)
- .withLineSeparator(CRLF);
+ .withRecordSeparator(CRLF);
/**
* Excel file format (using a comma as the value delimiter). Note that the actual value delimiter used by Excel is
@@ -108,7 +108,7 @@ public class CSVFormat implements Serializable {
PRISTINE
.withDelimiter(COMMA)
.withQuoteChar(DOUBLE_QUOTE)
- .withLineSeparator(CRLF);
+ .withRecordSeparator(CRLF);
/** Tab-delimited format, with quote; leading and trailing spaces ignored. */
public static final CSVFormat TDF =
@@ -117,7 +117,7 @@ public class CSVFormat implements Serializable {
.withQuoteChar(DOUBLE_QUOTE)
.withIgnoreSurroundingSpaces(true)
.withIgnoreEmptyLines(true)
- .withLineSeparator(CRLF);
+ .withRecordSeparator(CRLF);
/**
* Default MySQL format used by the SELECT INTO OUTFILE and LOAD DATA INFILE operations. This is
@@ -131,7 +131,7 @@ public class CSVFormat implements Serializable {
PRISTINE
.withDelimiter(TAB)
.withEscape(ESCAPE)
- .withLineSeparator(LF);
+ .withRecordSeparator(LF);
/**
* Creates a basic CSV format.
@@ -161,7 +161,7 @@ public class CSVFormat implements Serializable {
* true when whitespaces enclosing values should be ignored
* @param ignoreEmptyLines
* true when the parser should skip empty lines
- * @param lineSeparator
+ * @param recordSeparator
* the line separator to use for output
* @param header
* the header
@@ -181,7 +181,7 @@ public class CSVFormat implements Serializable {
this.escape = escape;
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
this.ignoreEmptyLines = ignoreEmptyLines;
- this.lineSeparator = lineSeparator;
+ this.recordSeparator = lineSeparator;
this.header = header;
}
@@ -262,7 +262,7 @@ public class CSVFormat implements Serializable {
*/
public CSVFormat withDelimiter(final char delimiter) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -301,7 +301,7 @@ public class CSVFormat implements Serializable {
throw new IllegalArgumentException("The quoteChar cannot be a line break");
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -353,7 +353,7 @@ public class CSVFormat implements Serializable {
throw new IllegalArgumentException("The comment start character cannot be a line break");
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -403,7 +403,7 @@ public class CSVFormat implements Serializable {
throw new IllegalArgumentException("The escape character cannot be a line break");
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -435,7 +435,7 @@ public class CSVFormat implements Serializable {
*/
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -458,7 +458,7 @@ public class CSVFormat implements Serializable {
*/
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -466,34 +466,34 @@ public class CSVFormat implements Serializable {
*
* @return the line separator
*/
- public String getLineSeparator() {
- return lineSeparator;
+ public String getRecordSeparator() {
+ return recordSeparator;
}
/**
- * Returns a copy of this format using the specified output line separator.
+ * Returns a copy of this format using the specified output record separator.
*
- * @param lineSeparator
- * the line separator to use for output.
+ * @param recordSeparator
+ * the record separator to use for output.
*
- * @return A copy of this format using the specified output line separator
+ * @return A copy of this format using the specified output record separator
*/
- public CSVFormat withLineSeparator(final char lineSeparator) {
+ public CSVFormat withRecordSeparator(final char recordSeparator) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, String.valueOf(lineSeparator), header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, String.valueOf(recordSeparator), header);
}
/**
- * Returns a copy of this format using the specified output line separator.
+ * Returns a copy of this format using the specified output record separator.
*
- * @param lineSeparator
- * the line separator to use for output.
+ * @param recordSeparator
+ * the record separator to use for output.
*
- * @return A copy of this format using the specified output line separator
+ * @return A copy of this format using the specified output record separator
*/
- public CSVFormat withLineSeparator(final String lineSeparator) {
+ public CSVFormat withRecordSeparator(final String recordSeparator) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
@@ -506,7 +506,7 @@ public class CSVFormat implements Serializable {
*/
public CSVFormat withQuotePolicy(final Quote quotePolicy) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
String[] getHeader() {
@@ -534,7 +534,7 @@ public class CSVFormat implements Serializable {
*/
public CSVFormat withHeader(final String... header) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
- ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
}
/**
diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index e1984c07..f6384c1f 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -70,7 +70,7 @@ public class CSVPrinter implements Flushable, Closeable {
* Outputs the line separator.
*/
public void println() throws IOException {
- out.append(format.getLineSeparator());
+ out.append(format.getRecordSeparator());
newLine = true;
}
diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
index 3c37e1d0..ae4f9a50 100644
--- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
@@ -46,7 +46,7 @@ public class CSVFormatTest {
format.withQuoteChar('?');
format.withQuotePolicy(Quote.ALL);
format.withCommentStart('?');
- format.withLineSeparator("?");
+ format.withRecordSeparator("?");
format.withEscape('?');
format.withIgnoreSurroundingSpaces(false);
format.withIgnoreEmptyLines(false);
@@ -55,7 +55,7 @@ public class CSVFormatTest {
assertEquals('!', format.getQuoteChar().charValue());
assertEquals('!', format.getCommentStart().charValue());
assertEquals('!', format.getEscape().charValue());
- assertEquals(CRLF, format.getLineSeparator());
+ assertEquals(CRLF, format.getRecordSeparator());
assertTrue(format.getIgnoreSurroundingSpaces());
assertTrue(format.getIgnoreEmptyLines());
@@ -71,7 +71,7 @@ public class CSVFormatTest {
assertEquals('?', format.withQuoteChar('?').getQuoteChar().charValue());
assertEquals(Quote.ALL, format.withQuotePolicy(Quote.ALL).getQuotePolicy());
assertEquals('?', format.withCommentStart('?').getCommentStart().charValue());
- assertEquals("?", format.withLineSeparator("?").getLineSeparator());
+ assertEquals("?", format.withRecordSeparator("?").getRecordSeparator());
assertEquals('?', format.withEscape('?').getEscape().charValue());
assertFalse(format.withIgnoreSurroundingSpaces(false).getIgnoreSurroundingSpaces());
@@ -214,7 +214,7 @@ public class CSVFormatTest {
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteChar(), format.getQuoteChar());
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
- assertEquals("line separator", CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
+ assertEquals("line separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator());
assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
assertEquals("empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());
diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java
index 4404cd27..3a7edf9f 100644
--- a/src/test/java/org/apache/commons/csv/CSVParserTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java
@@ -313,7 +313,7 @@ public class CSVParserTest {
final CSVFormat format = new CSVFormat(',').withQuoteChar('\'').withEscape('/')
- .withIgnoreEmptyLines(true).withLineSeparator(CRLF);
+ .withIgnoreEmptyLines(true).withRecordSeparator(CRLF);
final CSVParser parser = new CSVParser(code, format);
final List records = parser.getRecords();
@@ -343,7 +343,7 @@ public class CSVParserTest {
final CSVFormat format = new CSVFormat(',').withEscape('/')
- .withIgnoreEmptyLines(true).withLineSeparator(CRLF);
+ .withIgnoreEmptyLines(true).withRecordSeparator(CRLF);
final CSVParser parser = new CSVParser(code, format);
final List records = parser.getRecords();
@@ -622,7 +622,7 @@ public class CSVParserTest {
@Test
public void testGetRecordWithMultiiLineValues() throws Exception {
final CSVParser parser = new CSVParser("\"a\r\n1\",\"a\r\n2\"" + CRLF + "\"b\r\n1\",\"b\r\n2\"" + CRLF + "\"c\r\n1\",\"c\r\n2\"",
- CSVFormat.DEFAULT.withLineSeparator(CRLF));
+ CSVFormat.DEFAULT.withRecordSeparator(CRLF));
CSVRecord record;
assertEquals(0, parser.getRecordNumber());
assertEquals(0, parser.getLineNumber());
@@ -654,7 +654,7 @@ public class CSVParserTest {
}
private void validateRecordNumbers(String lineSeparator) throws IOException {
- final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
+ final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));
CSVRecord record;
assertEquals(0, parser.getRecordNumber());
assertNotNull(record = parser.nextRecord());
@@ -671,7 +671,7 @@ public class CSVParserTest {
}
private void validateLineNumbers(String lineSeparator) throws IOException {
- final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
+ final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));
assertEquals(0, parser.getLineNumber());
assertNotNull(parser.nextRecord());
assertEquals(1, parser.getLineNumber());
diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
index 8f108894..f1e5f863 100644
--- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -51,7 +51,7 @@ public class CSVPrinterTest {
return sb.toString();
}
- String lineSeparator = CSVFormat.DEFAULT.getLineSeparator();
+ String recordSeparator = CSVFormat.DEFAULT.getRecordSeparator();
public void doOneRandom(final CSVFormat format) throws Exception {
final Random r = new Random();
@@ -155,7 +155,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecords(new String[][] { { "r1c1", "r1c2" }, { "r2c1", "r2c2" } });
- assertEquals("r1c1,r1c2" + lineSeparator + "r2c1,r2c2" + lineSeparator, sw.toString());
+ assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
}
@Test
@@ -163,7 +163,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecords(new List[] { Arrays.asList(new String[] { "r1c1", "r1c2" }), Arrays.asList(new String[] { "r2c1", "r2c2" }) });
- assertEquals("r1c1,r1c2" + lineSeparator + "r2c1,r2c2" + lineSeparator, sw.toString());
+ assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
}
@Test
@@ -171,7 +171,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecords(Arrays.asList(new String[][] { { "r1c1", "r1c2" }, { "r2c1", "r2c2" } }));
- assertEquals("r1c1,r1c2" + lineSeparator + "r2c1,r2c2" + lineSeparator, sw.toString());
+ assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
}
@Test
@@ -180,7 +180,7 @@ public class CSVPrinterTest {
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecords(Arrays.asList(new List[] { Arrays.asList(new String[] { "r1c1", "r1c2" }),
Arrays.asList(new String[] { "r2c1", "r2c2" }) }));
- assertEquals("r1c1,r1c2" + lineSeparator + "r2c1,r2c2" + lineSeparator, sw.toString());
+ assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
}
@Test
@@ -188,7 +188,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecord("a", "b");
- assertEquals("a,b" + lineSeparator, sw.toString());
+ assertEquals("a,b" + recordSeparator, sw.toString());
}
@Test
@@ -196,7 +196,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL);
printer.printRecord("a,b", "b");
- assertEquals("\"a,b\",b" + lineSeparator, sw.toString());
+ assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
}
@Test
@@ -211,7 +211,7 @@ public class CSVPrinterTest {
stmt.execute("insert into TEST values(2, 'r2')");
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecords(stmt.executeQuery("select ID, NAME from TEST"));
- assertEquals("1,r1" + lineSeparator + "2,r2" + lineSeparator, sw.toString());
+ assertEquals("1,r1" + recordSeparator + "2,r2" + recordSeparator, sw.toString());
} finally {
connection.close();
}
@@ -223,7 +223,7 @@ public class CSVPrinterTest {
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentStart('#'));
printer.printComment("This is a comment\non multiple lines");
- assertEquals("# This is a comment" + lineSeparator + "# on multiple lines" + lineSeparator, sw.toString());
+ assertEquals("# This is a comment" + recordSeparator + "# on multiple lines" + recordSeparator, sw.toString());
}
@Test
@@ -231,7 +231,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b");
- assertEquals("a,b" + lineSeparator, sw.toString());
+ assertEquals("a,b" + recordSeparator, sw.toString());
}
@Test
@@ -239,7 +239,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a,b", "b");
- assertEquals("\"a,b\",b" + lineSeparator, sw.toString());
+ assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
}
@Test
@@ -247,7 +247,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a, b", "b ");
- assertEquals("\"a, b\",\"b \"" + lineSeparator, sw.toString());
+ assertEquals("\"a, b\",\"b \"" + recordSeparator, sw.toString());
}
@Test
@@ -255,7 +255,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\"c");
- assertEquals("a,\"b\"\"c\"" + lineSeparator, sw.toString());
+ assertEquals("a,\"b\"\"c\"" + recordSeparator, sw.toString());
}
@Test
@@ -263,7 +263,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\nc");
- assertEquals("a,\"b\nc\"" + lineSeparator, sw.toString());
+ assertEquals("a,\"b\nc\"" + recordSeparator, sw.toString());
}
@Test
@@ -271,7 +271,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\r\nc");
- assertEquals("a,\"b\r\nc\"" + lineSeparator, sw.toString());
+ assertEquals("a,\"b\r\nc\"" + recordSeparator, sw.toString());
}
@Test
@@ -279,7 +279,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\\c");
- assertEquals("a,b\\c" + lineSeparator, sw.toString());
+ assertEquals("a,b\\c" + recordSeparator, sw.toString());
}
@Test
@@ -287,7 +287,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", null, "b");
- assertEquals("a,,b" + lineSeparator, sw.toString());
+ assertEquals("a,,b" + recordSeparator, sw.toString());
}
@Test
@@ -295,7 +295,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.ALL));
printer.printRecord("a", "b\nc", "d");
- assertEquals("\"a\",\"b\nc\",\"d\"" + lineSeparator, sw.toString());
+ assertEquals("\"a\",\"b\nc\",\"d\"" + recordSeparator, sw.toString());
}
@Test
@@ -303,7 +303,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.NON_NUMERIC));
printer.printRecord("a", "b\nc", Integer.valueOf(1));
- assertEquals("\"a\",\"b\nc\",1" + lineSeparator, sw.toString());
+ assertEquals("\"a\",\"b\nc\",1" + recordSeparator, sw.toString());
}
@Test
@@ -320,7 +320,7 @@ public class CSVPrinterTest {
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentStart('#'));
printer.printComment("This is a comment");
- assertEquals("# This is a comment" + lineSeparator, sw.toString());
+ assertEquals("# This is a comment" + recordSeparator, sw.toString());
}
}