Skip to content

Commit 73ec29f

Browse files
committed
Rename "line separator" to "record separator".
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398911 13f79535-47bb-0310-9956-ffa450edef68
1 parent d8eaf1c commit 73ec29f

5 files changed

Lines changed: 60 additions & 60 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class CSVFormat implements Serializable {
5555
private final Character escape;
5656
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
5757
private final boolean ignoreEmptyLines;
58-
private final String lineSeparator; // for outputs
58+
private final String recordSeparator; // for outputs
5959
private final String[] header;
6060

6161
/**
@@ -77,7 +77,7 @@ public class CSVFormat implements Serializable {
7777
.withDelimiter(COMMA)
7878
.withQuoteChar(DOUBLE_QUOTE)
7979
.withIgnoreEmptyLines(true)
80-
.withLineSeparator(CRLF);
80+
.withRecordSeparator(CRLF);
8181

8282
/**
8383
* Comma separated format as defined by <a href="http://tools.ietf.org/html/rfc4180">RFC 4180</a>.
@@ -92,7 +92,7 @@ public class CSVFormat implements Serializable {
9292
PRISTINE
9393
.withDelimiter(COMMA)
9494
.withQuoteChar(DOUBLE_QUOTE)
95-
.withLineSeparator(CRLF);
95+
.withRecordSeparator(CRLF);
9696

9797
/**
9898
* 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 {
108108
PRISTINE
109109
.withDelimiter(COMMA)
110110
.withQuoteChar(DOUBLE_QUOTE)
111-
.withLineSeparator(CRLF);
111+
.withRecordSeparator(CRLF);
112112

113113
/** Tab-delimited format, with quote; leading and trailing spaces ignored. */
114114
public static final CSVFormat TDF =
@@ -117,7 +117,7 @@ public class CSVFormat implements Serializable {
117117
.withQuoteChar(DOUBLE_QUOTE)
118118
.withIgnoreSurroundingSpaces(true)
119119
.withIgnoreEmptyLines(true)
120-
.withLineSeparator(CRLF);
120+
.withRecordSeparator(CRLF);
121121

122122
/**
123123
* Default MySQL format used by the <tt>SELECT INTO OUTFILE</tt> and <tt>LOAD DATA INFILE</tt> operations. This is
@@ -131,7 +131,7 @@ public class CSVFormat implements Serializable {
131131
PRISTINE
132132
.withDelimiter(TAB)
133133
.withEscape(ESCAPE)
134-
.withLineSeparator(LF);
134+
.withRecordSeparator(LF);
135135

136136
/**
137137
* Creates a basic CSV format.
@@ -161,7 +161,7 @@ public CSVFormat(char delimiter){
161161
* <tt>true</tt> when whitespaces enclosing values should be ignored
162162
* @param ignoreEmptyLines
163163
* <tt>true</tt> when the parser should skip empty lines
164-
* @param lineSeparator
164+
* @param recordSeparator
165165
* the line separator to use for output
166166
* @param header
167167
* the header
@@ -181,7 +181,7 @@ public CSVFormat(char delimiter){
181181
this.escape = escape;
182182
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
183183
this.ignoreEmptyLines = ignoreEmptyLines;
184-
this.lineSeparator = lineSeparator;
184+
this.recordSeparator = lineSeparator;
185185
this.header = header;
186186
}
187187

@@ -262,7 +262,7 @@ public char getDelimiter() {
262262
*/
263263
public CSVFormat withDelimiter(final char delimiter) {
264264
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
265-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
265+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
266266
}
267267

268268
/**
@@ -301,7 +301,7 @@ public CSVFormat withQuoteChar(final Character quoteChar) {
301301
throw new IllegalArgumentException("The quoteChar cannot be a line break");
302302
}
303303
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
304-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
304+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
305305
}
306306

307307
/**
@@ -353,7 +353,7 @@ public CSVFormat withCommentStart(final Character commentStart) {
353353
throw new IllegalArgumentException("The comment start character cannot be a line break");
354354
}
355355
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
356-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
356+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
357357
}
358358

359359
/**
@@ -403,7 +403,7 @@ public CSVFormat withEscape(final Character escape) {
403403
throw new IllegalArgumentException("The escape character cannot be a line break");
404404
}
405405
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
406-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
406+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
407407
}
408408

409409
/**
@@ -435,7 +435,7 @@ public boolean getIgnoreSurroundingSpaces() {
435435
*/
436436
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
437437
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
438-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
438+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
439439
}
440440

441441
/**
@@ -458,42 +458,42 @@ public boolean getIgnoreEmptyLines() {
458458
*/
459459
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
460460
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
461-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
461+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
462462
}
463463

464464
/**
465465
* Returns the line separator delimiting output records.
466466
*
467467
* @return the line separator
468468
*/
469-
public String getLineSeparator() {
470-
return lineSeparator;
469+
public String getRecordSeparator() {
470+
return recordSeparator;
471471
}
472472

473473
/**
474-
* Returns a copy of this format using the specified output line separator.
474+
* Returns a copy of this format using the specified output record separator.
475475
*
476-
* @param lineSeparator
477-
* the line separator to use for output.
476+
* @param recordSeparator
477+
* the record separator to use for output.
478478
*
479-
* @return A copy of this format using the specified output line separator
479+
* @return A copy of this format using the specified output record separator
480480
*/
481-
public CSVFormat withLineSeparator(final char lineSeparator) {
481+
public CSVFormat withRecordSeparator(final char recordSeparator) {
482482
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
483-
ignoreSurroundingSpaces, ignoreEmptyLines, String.valueOf(lineSeparator), header);
483+
ignoreSurroundingSpaces, ignoreEmptyLines, String.valueOf(recordSeparator), header);
484484
}
485485

486486
/**
487-
* Returns a copy of this format using the specified output line separator.
487+
* Returns a copy of this format using the specified output record separator.
488488
*
489-
* @param lineSeparator
490-
* the line separator to use for output.
489+
* @param recordSeparator
490+
* the record separator to use for output.
491491
*
492-
* @return A copy of this format using the specified output line separator
492+
* @return A copy of this format using the specified output record separator
493493
*/
494-
public CSVFormat withLineSeparator(final String lineSeparator) {
494+
public CSVFormat withRecordSeparator(final String recordSeparator) {
495495
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
496-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
496+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
497497
}
498498

499499
/**
@@ -506,7 +506,7 @@ public CSVFormat withLineSeparator(final String lineSeparator) {
506506
*/
507507
public CSVFormat withQuotePolicy(final Quote quotePolicy) {
508508
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
509-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
509+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
510510
}
511511

512512
String[] getHeader() {
@@ -534,7 +534,7 @@ String[] getHeader() {
534534
*/
535535
public CSVFormat withHeader(final String... header) {
536536
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
537-
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
537+
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, header);
538538
}
539539

540540
/**

src/main/java/org/apache/commons/csv/CSVPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public CSVPrinter(final Appendable out, final CSVFormat format) {
7070
* Outputs the line separator.
7171
*/
7272
public void println() throws IOException {
73-
out.append(format.getLineSeparator());
73+
out.append(format.getRecordSeparator());
7474
newLine = true;
7575
}
7676

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testImmutalibity() {
4646
format.withQuoteChar('?');
4747
format.withQuotePolicy(Quote.ALL);
4848
format.withCommentStart('?');
49-
format.withLineSeparator("?");
49+
format.withRecordSeparator("?");
5050
format.withEscape('?');
5151
format.withIgnoreSurroundingSpaces(false);
5252
format.withIgnoreEmptyLines(false);
@@ -55,7 +55,7 @@ public void testImmutalibity() {
5555
assertEquals('!', format.getQuoteChar().charValue());
5656
assertEquals('!', format.getCommentStart().charValue());
5757
assertEquals('!', format.getEscape().charValue());
58-
assertEquals(CRLF, format.getLineSeparator());
58+
assertEquals(CRLF, format.getRecordSeparator());
5959

6060
assertTrue(format.getIgnoreSurroundingSpaces());
6161
assertTrue(format.getIgnoreEmptyLines());
@@ -71,7 +71,7 @@ public void testMutators() {
7171
assertEquals('?', format.withQuoteChar('?').getQuoteChar().charValue());
7272
assertEquals(Quote.ALL, format.withQuotePolicy(Quote.ALL).getQuotePolicy());
7373
assertEquals('?', format.withCommentStart('?').getCommentStart().charValue());
74-
assertEquals("?", format.withLineSeparator("?").getLineSeparator());
74+
assertEquals("?", format.withRecordSeparator("?").getRecordSeparator());
7575
assertEquals('?', format.withEscape('?').getEscape().charValue());
7676

7777
assertFalse(format.withIgnoreSurroundingSpaces(false).getIgnoreSurroundingSpaces());
@@ -214,7 +214,7 @@ public void testSerialization() throws Exception {
214214
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
215215
assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteChar(), format.getQuoteChar());
216216
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
217-
assertEquals("line separator", CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
217+
assertEquals("line separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator());
218218
assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
219219
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
220220
assertEquals("empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void testBackslashEscaping() throws IOException {
313313

314314

315315
final CSVFormat format = new CSVFormat(',').withQuoteChar('\'').withEscape('/')
316-
.withIgnoreEmptyLines(true).withLineSeparator(CRLF);
316+
.withIgnoreEmptyLines(true).withRecordSeparator(CRLF);
317317

318318
final CSVParser parser = new CSVParser(code, format);
319319
final List<CSVRecord> records = parser.getRecords();
@@ -343,7 +343,7 @@ public void testBackslashEscaping2() throws IOException {
343343

344344

345345
final CSVFormat format = new CSVFormat(',').withEscape('/')
346-
.withIgnoreEmptyLines(true).withLineSeparator(CRLF);
346+
.withIgnoreEmptyLines(true).withRecordSeparator(CRLF);
347347

348348
final CSVParser parser = new CSVParser(code, format);
349349
final List<CSVRecord> records = parser.getRecords();
@@ -622,7 +622,7 @@ public void testGetRecordNumberWithLF() throws Exception {
622622
@Test
623623
public void testGetRecordWithMultiiLineValues() throws Exception {
624624
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\"",
625-
CSVFormat.DEFAULT.withLineSeparator(CRLF));
625+
CSVFormat.DEFAULT.withRecordSeparator(CRLF));
626626
CSVRecord record;
627627
assertEquals(0, parser.getRecordNumber());
628628
assertEquals(0, parser.getLineNumber());
@@ -654,7 +654,7 @@ public void testGetRecordNumberWithCR() throws Exception {
654654
}
655655

656656
private void validateRecordNumbers(String lineSeparator) throws IOException {
657-
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
657+
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));
658658
CSVRecord record;
659659
assertEquals(0, parser.getRecordNumber());
660660
assertNotNull(record = parser.nextRecord());
@@ -671,7 +671,7 @@ private void validateRecordNumbers(String lineSeparator) throws IOException {
671671
}
672672

673673
private void validateLineNumbers(String lineSeparator) throws IOException {
674-
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
674+
final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator));
675675
assertEquals(0, parser.getLineNumber());
676676
assertNotNull(parser.nextRecord());
677677
assertEquals(1, parser.getLineNumber());

0 commit comments

Comments
 (0)