Skip to content

Commit 040c260

Browse files
committed
Rename withCommentStart to withCommentMarker to avoid confusion because there is no corresponding withCommentStop method
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1610494 13f79535-47bb-0310-9956-ffa450edef68
1 parent bb54feb commit 040c260

6 files changed

Lines changed: 34 additions & 34 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,32 +745,32 @@ private void validate() throws IllegalArgumentException {
745745
*
746746
* Note that the comment start character is only recognized at the start of a line.
747747
*
748-
* @param commentStart
748+
* @param commentMarker
749749
* the comment start marker
750750
* @return A new CSVFormat that is equal to this one but with the specified character as the comment start marker
751751
* @throws IllegalArgumentException
752752
* thrown if the specified character is a line break
753753
*/
754-
public CSVFormat withCommentStart(final char commentStart) {
755-
return withCommentStart(Character.valueOf(commentStart));
754+
public CSVFormat withCommentMarker(final char commentMarker) {
755+
return withCommentMarker(Character.valueOf(commentMarker));
756756
}
757757

758758
/**
759759
* Sets the comment start marker of the format to the specified character.
760760
*
761761
* Note that the comment start character is only recognized at the start of a line.
762762
*
763-
* @param commentStart
763+
* @param commentMarker
764764
* the comment start marker, use {@code null} to disable
765765
* @return A new CSVFormat that is equal to this one but with the specified character as the comment start marker
766766
* @throws IllegalArgumentException
767767
* thrown if the specified character is a line break
768768
*/
769-
public CSVFormat withCommentStart(final Character commentStart) {
770-
if (isLineBreak(commentStart)) {
771-
throw new IllegalArgumentException("The comment start character cannot be a line break");
769+
public CSVFormat withCommentMarker(final Character commentMarker) {
770+
if (isLineBreak(commentMarker)) {
771+
throw new IllegalArgumentException("The comment start marker character cannot be a line break");
772772
}
773-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
773+
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentMarker, escape,
774774
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
775775
ignoreEmptyHeaders);
776776
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void testCSVFile() throws Exception {
100100
} else if ("IgnoreSpaces".equalsIgnoreCase(option_parts[0])) {
101101
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(option_parts[1]));
102102
} else if ("CommentStart".equalsIgnoreCase(option_parts[0])) {
103-
format = format.withCommentStart(option_parts[1].charAt(0));
103+
format = format.withCommentMarker(option_parts[1].charAt(0));
104104
} else if ("CheckComments".equalsIgnoreCase(option_parts[0])) {
105105
checkComments = true;
106106
} else {
@@ -144,7 +144,7 @@ public void testCSVUrl() throws Exception {
144144
} else if ("IgnoreSpaces".equalsIgnoreCase(option_parts[0])) {
145145
format = format.withIgnoreSurroundingSpaces(Boolean.parseBoolean(option_parts[1]));
146146
} else if ("CommentStart".equalsIgnoreCase(option_parts[0])) {
147-
format = format.withCommentStart(option_parts[1].charAt(0));
147+
format = format.withCommentMarker(option_parts[1].charAt(0));
148148
} else if ("CheckComments".equalsIgnoreCase(option_parts[0])) {
149149
checkComments = true;
150150
} else {

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private static CSVFormat copy(final CSVFormat format) {
5454

5555
@Test(expected = IllegalArgumentException.class)
5656
public void testDelimiterSameAsCommentStartThrowsException() {
57-
CSVFormat.DEFAULT.withDelimiter('!').withCommentStart('!');
57+
CSVFormat.DEFAULT.withDelimiter('!').withCommentMarker('!');
5858
}
5959

6060
@Test(expected = IllegalArgumentException.class)
@@ -87,10 +87,10 @@ public void testEquals() {
8787
public void testEqualsCommentStart() {
8888
final CSVFormat right = CSVFormat.newFormat('\'')
8989
.withQuoteChar('"')
90-
.withCommentStart('#')
90+
.withCommentMarker('#')
9191
.withQuotePolicy(Quote.ALL);
9292
final CSVFormat left = right
93-
.withCommentStart('!');
93+
.withCommentMarker('!');
9494

9595
assertNotEquals(right, left);
9696
}
@@ -107,7 +107,7 @@ public void testEqualsDelimiter() {
107107
public void testEqualsEscape() {
108108
final CSVFormat right = CSVFormat.newFormat('\'')
109109
.withQuoteChar('"')
110-
.withCommentStart('#')
110+
.withCommentMarker('#')
111111
.withEscape('+')
112112
.withQuotePolicy(Quote.ALL);
113113
final CSVFormat left = right
@@ -120,7 +120,7 @@ public void testEqualsEscape() {
120120
public void testEqualsHeader() {
121121
final CSVFormat right = CSVFormat.newFormat('\'')
122122
.withRecordSeparator(CR)
123-
.withCommentStart('#')
123+
.withCommentMarker('#')
124124
.withEscape('+')
125125
.withHeader("One", "Two", "Three")
126126
.withIgnoreEmptyLines(true)
@@ -136,7 +136,7 @@ public void testEqualsHeader() {
136136
@Test
137137
public void testEqualsIgnoreEmptyLines() {
138138
final CSVFormat right = CSVFormat.newFormat('\'')
139-
.withCommentStart('#')
139+
.withCommentMarker('#')
140140
.withEscape('+')
141141
.withIgnoreEmptyLines(true)
142142
.withIgnoreSurroundingSpaces(true)
@@ -151,7 +151,7 @@ public void testEqualsIgnoreEmptyLines() {
151151
@Test
152152
public void testEqualsIgnoreSurroundingSpaces() {
153153
final CSVFormat right = CSVFormat.newFormat('\'')
154-
.withCommentStart('#')
154+
.withCommentMarker('#')
155155
.withEscape('+')
156156
.withIgnoreSurroundingSpaces(true)
157157
.withQuoteChar('"')
@@ -185,7 +185,7 @@ public void testEqualsQuotePolicy() {
185185
public void testEqualsRecordSeparator() {
186186
final CSVFormat right = CSVFormat.newFormat('\'')
187187
.withRecordSeparator(CR)
188-
.withCommentStart('#')
188+
.withCommentMarker('#')
189189
.withEscape('+')
190190
.withIgnoreEmptyLines(true)
191191
.withIgnoreSurroundingSpaces(true)
@@ -201,7 +201,7 @@ public void testEqualsRecordSeparator() {
201201
public void testEqualsNullString() {
202202
final CSVFormat right = CSVFormat.newFormat('\'')
203203
.withRecordSeparator(CR)
204-
.withCommentStart('#')
204+
.withCommentMarker('#')
205205
.withEscape('+')
206206
.withIgnoreEmptyLines(true)
207207
.withIgnoreSurroundingSpaces(true)
@@ -218,7 +218,7 @@ public void testEqualsNullString() {
218218
public void testEqualsSkipHeaderRecord() {
219219
final CSVFormat right = CSVFormat.newFormat('\'')
220220
.withRecordSeparator(CR)
221-
.withCommentStart('#')
221+
.withCommentMarker('#')
222222
.withEscape('+')
223223
.withIgnoreEmptyLines(true)
224224
.withIgnoreSurroundingSpaces(true)
@@ -234,13 +234,13 @@ public void testEqualsSkipHeaderRecord() {
234234

235235
@Test(expected = IllegalArgumentException.class)
236236
public void testEscapeSameAsCommentStartThrowsException() {
237-
CSVFormat.DEFAULT.withEscape('!').withCommentStart('!');
237+
CSVFormat.DEFAULT.withEscape('!').withCommentMarker('!');
238238
}
239239

240240
@Test(expected = IllegalArgumentException.class)
241241
public void testEscapeSameAsCommentStartThrowsExceptionForWrapperType() {
242242
// Cannot assume that callers won't use different Character objects
243-
CSVFormat.DEFAULT.withEscape(new Character('!')).withCommentStart(new Character('!'));
243+
CSVFormat.DEFAULT.withEscape(new Character('!')).withCommentMarker(new Character('!'));
244244
}
245245

246246
@Test
@@ -275,13 +275,13 @@ public void testNullRecordSeparatorCsv106() {
275275

276276
@Test(expected = IllegalArgumentException.class)
277277
public void testQuoteCharSameAsCommentStartThrowsException() {
278-
CSVFormat.DEFAULT.withQuoteChar('!').withCommentStart('!');
278+
CSVFormat.DEFAULT.withQuoteChar('!').withCommentMarker('!');
279279
}
280280

281281
@Test(expected = IllegalArgumentException.class)
282282
public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() {
283283
// Cannot assume that callers won't use different Character objects
284-
CSVFormat.DEFAULT.withQuoteChar(new Character('!')).withCommentStart('!');
284+
CSVFormat.DEFAULT.withQuoteChar(new Character('!')).withCommentMarker('!');
285285
}
286286

287287
@Test(expected = IllegalArgumentException.class)
@@ -330,13 +330,13 @@ public void testSerialization() throws Exception {
330330

331331
@Test
332332
public void testWithCommentStart() throws Exception {
333-
final CSVFormat formatWithCommentStart = CSVFormat.DEFAULT.withCommentStart('#');
333+
final CSVFormat formatWithCommentStart = CSVFormat.DEFAULT.withCommentMarker('#');
334334
assertEquals( Character.valueOf('#'), formatWithCommentStart.getCommentStart());
335335
}
336336

337337
@Test(expected = IllegalArgumentException.class)
338338
public void testWithCommentStartCRThrowsException() {
339-
CSVFormat.DEFAULT.withCommentStart(CR);
339+
CSVFormat.DEFAULT.withCommentMarker(CR);
340340
}
341341

342342
@Test

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public void testCarriageReturnLineFeedEndings() throws IOException {
242242
@Test(expected = NoSuchElementException.class)
243243
public void testClose() throws Exception {
244244
final Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
245-
final CSVParser parser = CSVFormat.DEFAULT.withCommentStart('#').withHeader().parse(in);
245+
final CSVParser parser = CSVFormat.DEFAULT.withCommentMarker('#').withHeader().parse(in);
246246
final Iterator<CSVRecord> records = parser.iterator();
247247
assertTrue(records.hasNext());
248248
parser.close();
@@ -288,7 +288,7 @@ public void testDefaultFormat() throws IOException {
288288
{"\n", " ", "#"},
289289
};
290290

291-
format = CSVFormat.DEFAULT.withCommentStart('#');
291+
format = CSVFormat.DEFAULT.withCommentMarker('#');
292292
parser.close();
293293
parser = CSVParser.parse(code, format);
294294
records = parser.getRecords();
@@ -671,7 +671,7 @@ public void testHeaderMissingWithNull() throws Exception {
671671
public void testHeaderComment() throws Exception {
672672
final Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
673673

674-
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withCommentStart('#').withHeader().parse(in).iterator();
674+
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withCommentMarker('#').withHeader().parse(in).iterator();
675675

676676
for (int i = 0; i < 2; i++) {
677677
assertTrue(records.hasNext());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void testJdbcPrinter() throws IOException, ClassNotFoundException, SQLExc
233233
@Test
234234
public void testMultiLineComment() throws IOException {
235235
final StringWriter sw = new StringWriter();
236-
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentStart('#'));
236+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentMarker('#'));
237237
printer.printComment("This is a comment\non multiple lines");
238238

239239
assertEquals("# This is a comment" + recordSeparator + "# on multiple lines" + recordSeparator, sw.toString());
@@ -387,7 +387,7 @@ public void testPlainQuoted() throws IOException {
387387
@Test
388388
public void testSingleLineComment() throws IOException {
389389
final StringWriter sw = new StringWriter();
390-
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentStart('#'));
390+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentMarker('#'));
391391
printer.printComment("This is a comment");
392392

393393
assertEquals("# This is a comment" + recordSeparator, sw.toString());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testComments() throws IOException {
122122
"third,line,#no-comment\n"+
123123
"# penultimate comment\n"+
124124
"# Final comment\n";
125-
final CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#');
125+
final CSVFormat format = CSVFormat.DEFAULT.withCommentMarker('#');
126126
final Lexer parser = getLexer(code, format);
127127

128128
assertThat(parser.nextToken(new Token()), matches(TOKEN, "first"));
@@ -158,7 +158,7 @@ public void testCommentsAndEmptyLines() throws IOException {
158158
"\n"+ // 6b
159159
"\n"+ // 6c
160160
"# Final comment\n"; // 7
161-
final CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#').withIgnoreEmptyLines(false);
161+
final CSVFormat format = CSVFormat.DEFAULT.withCommentMarker('#').withIgnoreEmptyLines(false);
162162
assertFalse("Should not ignore empty lines", format.isIgnoringEmptyLines());
163163

164164
final Lexer parser = getLexer(code, format);
@@ -279,7 +279,7 @@ public void testNextToken6() throws IOException {
279279
* ;;
280280
*/
281281
final String code = "a;'b and '' more\n'\n!comment;;;;\n;;";
282-
final CSVFormat format = CSVFormat.DEFAULT.withQuoteChar('\'').withCommentStart('!').withDelimiter(';');
282+
final CSVFormat format = CSVFormat.DEFAULT.withQuoteChar('\'').withCommentMarker('!').withDelimiter(';');
283283
final Lexer parser = getLexer(code, format);
284284
assertThat(parser.nextToken(new Token()), matches(TOKEN, "a"));
285285
assertThat(parser.nextToken(new Token()), matches(EORECORD, "b and ' more\n"));

0 commit comments

Comments
 (0)