Skip to content

Commit 67d150a

Browse files
committed
Restore commentMarker property which was overridden during refactoring
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1612390 13f79535-47bb-0310-9956-ffa450edef68
1 parent f9a3162 commit 67d150a

5 files changed

Lines changed: 37 additions & 37 deletions

File tree

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public final class CSVFormat implements Serializable {
149149
private final char delimiter;
150150
private final Character quoteCharacter; // null if quoting is disabled
151151
private final QuoteMode quoteMode;
152-
private final Character commentStartCharacter; // null if commenting is disabled
152+
private final Character commentMarker; // null if commenting is disabled
153153
private final Character escapeCharacter; // null if escaping is disabled
154154
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
155155
private final boolean allowMissingColumnNames;
@@ -345,7 +345,7 @@ private CSVFormat(final char delimiter, final Character quoteChar,
345345
this.delimiter = delimiter;
346346
this.quoteCharacter = quoteChar;
347347
this.quoteMode = quoteMode;
348-
this.commentStartCharacter = commentStart;
348+
this.commentMarker = commentStart;
349349
this.escapeCharacter = escape;
350350
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
351351
this.allowMissingColumnNames = allowMissingColumnNames;
@@ -394,11 +394,11 @@ public boolean equals(final Object obj) {
394394
} else if (!quoteCharacter.equals(other.quoteCharacter)) {
395395
return false;
396396
}
397-
if (commentStartCharacter == null) {
398-
if (other.commentStartCharacter != null) {
397+
if (commentMarker == null) {
398+
if (other.commentMarker != null) {
399399
return false;
400400
}
401-
} else if (!commentStartCharacter.equals(other.commentStartCharacter)) {
401+
} else if (!commentMarker.equals(other.commentMarker)) {
402402
return false;
403403
}
404404
if (escapeCharacter == null) {
@@ -460,8 +460,8 @@ public String format(final Object... values) {
460460
*
461461
* @return the comment start marker, may be {@code null}
462462
*/
463-
public Character getCommentStartCharacter() {
464-
return commentStartCharacter;
463+
public Character getCommentMarker() {
464+
return commentMarker;
465465
}
466466

467467
/**
@@ -583,7 +583,7 @@ public int hashCode()
583583
result = prime * result + delimiter;
584584
result = prime * result + ((quoteMode == null) ? 0 : quoteMode.hashCode());
585585
result = prime * result + ((quoteCharacter == null) ? 0 : quoteCharacter.hashCode());
586-
result = prime * result + ((commentStartCharacter == null) ? 0 : commentStartCharacter.hashCode());
586+
result = prime * result + ((commentMarker == null) ? 0 : commentMarker.hashCode());
587587
result = prime * result + ((escapeCharacter == null) ? 0 : escapeCharacter.hashCode());
588588
result = prime * result + ((nullString == null) ? 0 : nullString.hashCode());
589589
result = prime * result + (ignoreSurroundingSpaces ? 1231 : 1237);
@@ -601,8 +601,8 @@ public int hashCode()
601601
*
602602
* @return {@code true} is comments are supported, {@code false} otherwise
603603
*/
604-
public boolean isCommentStartCharacterSet() {
605-
return commentStartCharacter != null;
604+
public boolean isCommentMarkerSet() {
605+
return commentMarker != null;
606606
}
607607

608608
/**
@@ -678,9 +678,9 @@ public String toString() {
678678
sb.append(' ');
679679
sb.append("QuoteChar=<").append(quoteCharacter).append('>');
680680
}
681-
if (isCommentStartCharacterSet()) {
681+
if (isCommentMarkerSet()) {
682682
sb.append(' ');
683-
sb.append("CommentStart=<").append(commentStartCharacter).append('>');
683+
sb.append("CommentStart=<").append(commentMarker).append('>');
684684
}
685685
if (isNullStringSet()) {
686686
sb.append(' ');
@@ -720,19 +720,19 @@ private void validate() throws IllegalArgumentException {
720720
"The escape character and the delimiter cannot be the same ('" + escapeCharacter + "')");
721721
}
722722

723-
if (commentStartCharacter != null && delimiter == commentStartCharacter.charValue()) {
723+
if (commentMarker != null && delimiter == commentMarker.charValue()) {
724724
throw new IllegalArgumentException(
725-
"The comment start character and the delimiter cannot be the same ('" + commentStartCharacter + "')");
725+
"The comment start character and the delimiter cannot be the same ('" + commentMarker + "')");
726726
}
727727

728-
if (quoteCharacter != null && quoteCharacter.equals(commentStartCharacter)) {
728+
if (quoteCharacter != null && quoteCharacter.equals(commentMarker)) {
729729
throw new IllegalArgumentException(
730-
"The comment start character and the quoteChar cannot be the same ('" + commentStartCharacter + "')");
730+
"The comment start character and the quoteChar cannot be the same ('" + commentMarker + "')");
731731
}
732732

733-
if (escapeCharacter != null && escapeCharacter.equals(commentStartCharacter)) {
733+
if (escapeCharacter != null && escapeCharacter.equals(commentMarker)) {
734734
throw new IllegalArgumentException(
735-
"The comment start and the escape character cannot be the same ('" + commentStartCharacter + "')");
735+
"The comment start and the escape character cannot be the same ('" + commentMarker + "')");
736736
}
737737

738738
if (escapeCharacter == null && quoteMode == QuoteMode.NONE) {
@@ -788,7 +788,7 @@ public CSVFormat withDelimiter(final char delimiter) {
788788
if (isLineBreak(delimiter)) {
789789
throw new IllegalArgumentException("The delimiter cannot be a line break");
790790
}
791-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
791+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
792792
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
793793
allowMissingColumnNames);
794794
}
@@ -819,7 +819,7 @@ public CSVFormat withEscape(final Character escape) {
819819
if (isLineBreak(escape)) {
820820
throw new IllegalArgumentException("The escape character cannot be a line break");
821821
}
822-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escape,
822+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escape,
823823
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
824824
allowMissingColumnNames);
825825
}
@@ -842,7 +842,7 @@ public CSVFormat withEscape(final Character escape) {
842842
* @see #withSkipHeaderRecord(boolean)
843843
*/
844844
public CSVFormat withHeader(final String... header) {
845-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
845+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
846846
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
847847
allowMissingColumnNames);
848848
}
@@ -856,7 +856,7 @@ public CSVFormat withHeader(final String... header) {
856856
* @return A new CSVFormat that is equal to this but with the specified missing column names behavior.
857857
*/
858858
public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNames) {
859-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
859+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
860860
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
861861
allowMissingColumnNames);
862862
}
@@ -870,7 +870,7 @@ public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNam
870870
* @return A new CSVFormat that is equal to this but with the specified empty line skipping behavior.
871871
*/
872872
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
873-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
873+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
874874
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
875875
allowMissingColumnNames);
876876
}
@@ -884,7 +884,7 @@ public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
884884
* @return A new CSVFormat that is equal to this but with the specified trimming behavior.
885885
*/
886886
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
887-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
887+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
888888
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
889889
allowMissingColumnNames);
890890
}
@@ -905,7 +905,7 @@ public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpac
905905
* @return A new CSVFormat that is equal to this but with the specified null conversion string.
906906
*/
907907
public CSVFormat withNullString(final String nullString) {
908-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
908+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
909909
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
910910
allowMissingColumnNames);
911911
}
@@ -936,7 +936,7 @@ public CSVFormat withQuote(final Character quoteChar) {
936936
if (isLineBreak(quoteChar)) {
937937
throw new IllegalArgumentException("The quoteChar cannot be a line break");
938938
}
939-
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStartCharacter, escapeCharacter,
939+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentMarker, escapeCharacter,
940940
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
941941
allowMissingColumnNames);
942942
}
@@ -950,7 +950,7 @@ public CSVFormat withQuote(final Character quoteChar) {
950950
* @return A new CSVFormat that is equal to this but with the specified quote policy
951951
*/
952952
public CSVFormat withQuoteMode(final QuoteMode quoteModePolicy) {
953-
return new CSVFormat(delimiter, quoteCharacter, quoteModePolicy, commentStartCharacter, escapeCharacter,
953+
return new CSVFormat(delimiter, quoteCharacter, quoteModePolicy, commentMarker, escapeCharacter,
954954
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
955955
allowMissingColumnNames);
956956
}
@@ -984,7 +984,7 @@ public CSVFormat withRecordSeparator(final char recordSeparator) {
984984
* if recordSeparator is none of CR, LF or CRLF
985985
*/
986986
public CSVFormat withRecordSeparator(final String recordSeparator) {
987-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
987+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
988988
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
989989
allowMissingColumnNames);
990990
}
@@ -999,7 +999,7 @@ public CSVFormat withRecordSeparator(final String recordSeparator) {
999999
* @see #withHeader(String...)
10001000
*/
10011001
public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
1002-
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
1002+
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
10031003
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
10041004
allowMissingColumnNames);
10051005
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ private void printAndQuote(final Object object, final CharSequence value,
297297
* If an I/O error occurs
298298
*/
299299
public void printComment(final String comment) throws IOException {
300-
if (!format.isCommentStartCharacterSet()) {
300+
if (!format.isCommentMarkerSet()) {
301301
return;
302302
}
303303
if (!newRecord) {
304304
println();
305305
}
306-
out.append(format.getCommentStartCharacter().charValue());
306+
out.append(format.getCommentMarker().charValue());
307307
out.append(SP);
308308
for (int i = 0; i < comment.length(); i++) {
309309
final char c = comment.charAt(i);
@@ -315,7 +315,7 @@ public void printComment(final String comment) throws IOException {
315315
//$FALL-THROUGH$ break intentionally excluded.
316316
case LF:
317317
println();
318-
out.append(format.getCommentStartCharacter().charValue());
318+
out.append(format.getCommentMarker().charValue());
319319
out.append(SP);
320320
break;
321321
default:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class Lexer implements Closeable {
6464
this.delimiter = format.getDelimiter();
6565
this.escape = mapNullToDisabled(format.getEscapeCharacter());
6666
this.quoteChar = mapNullToDisabled(format.getQuoteCharacter());
67-
this.commentStart = mapNullToDisabled(format.getCommentStartCharacter());
67+
this.commentStart = mapNullToDisabled(format.getCommentMarker());
6868
this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces();
6969
this.ignoreEmptyLines = format.getIgnoreEmptyLines();
7070
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public void testQuotePolicyNoneWithoutEscapeThrowsException() {
296296

297297
@Test
298298
public void testRFC4180() {
299-
assertEquals(null, RFC4180.getCommentStartCharacter());
299+
assertEquals(null, RFC4180.getCommentMarker());
300300
assertEquals(',', RFC4180.getDelimiter());
301301
assertEquals(null, RFC4180.getEscapeCharacter());
302302
assertFalse(RFC4180.getIgnoreEmptyLines());
@@ -321,7 +321,7 @@ public void testSerialization() throws Exception {
321321
assertNotNull(format);
322322
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
323323
assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteCharacter(), format.getQuoteCharacter());
324-
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStartCharacter(), format.getCommentStartCharacter());
324+
assertEquals("comment start", CSVFormat.DEFAULT.getCommentMarker(), format.getCommentMarker());
325325
assertEquals("record separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator());
326326
assertEquals("escape", CSVFormat.DEFAULT.getEscapeCharacter(), format.getEscapeCharacter());
327327
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
@@ -331,7 +331,7 @@ public void testSerialization() throws Exception {
331331
@Test
332332
public void testWithCommentStart() throws Exception {
333333
final CSVFormat formatWithCommentStart = CSVFormat.DEFAULT.withCommentMarker('#');
334-
assertEquals( Character.valueOf('#'), formatWithCommentStart.getCommentStartCharacter());
334+
assertEquals( Character.valueOf('#'), formatWithCommentStart.getCommentMarker());
335335
}
336336

337337
@Test(expected = IllegalArgumentException.class)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void testDefaultFormat() throws IOException {
274274
};
275275

276276
CSVFormat format = CSVFormat.DEFAULT;
277-
assertFalse(format.isCommentStartCharacterSet());
277+
assertFalse(format.isCommentMarkerSet());
278278

279279
CSVParser parser = CSVParser.parse(code, format);
280280
List<CSVRecord> records = parser.getRecords();

0 commit comments

Comments
 (0)