Skip to content

Commit 72dc36b

Browse files
committed
changing the comment with template to be more meaningful
1 parent 7f277bc commit 72dc36b

1 file changed

Lines changed: 55 additions & 6 deletions

File tree

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

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,46 @@ public Builder setHeader(final String... header) {
521521
}
522522

523523
/**
524-
* Sets the header comments set to the given values. The comments will be printed first with the provided comment marker set by {@link Builder#setCommentMarker(char)}, before the headers. This setting is ignored by the parser.
524+
* Gets the character marking the start of a line comment.
525+
* <p>
526+
* The comment format for each line is:
527+
* </p>
528+
* <pre>
529+
* CommentMarker SPACE CommentArrayElement
530+
* </pre>
531+
* <p>
532+
* For example, using a comment marker {@code '#'} and a comment array {@code comments ["line 1", "line 2"]}:
533+
* </p>
534+
* <pre>
535+
* # line 1
536+
* # line 2
537+
* </pre>
525538
*
539+
* @return the comment start marker, may be {@code null}
540+
*/
541+
542+
/**
543+
* Sets the header comments set to the given values. The comments will be printed first, before the headers. This setting is ignored by the parser.
544+
* <p>
545+
* Use {@link Builder#setCommentMarker(char)} or {@link Builder#setCommentMarker(Character)} to set the comment marker to be used with each comment.
546+
* </p>
547+
* <p>
548+
* If comment marker is not set (null) then none of header comments will get printed.
549+
* </p>
550+
* </p>
551+
* For an example, if you use comment marker and header comments as below
552+
* </p>
526553
* <pre>
527554
* builder.setHeaderComments(&quot;Generated by Apache Commons CSV.&quot;, Instant.now());
555+
* builder.setCommentMarker('#');
556+
* </pre>
557+
*<p>
558+
*you would get header lines printed something similar to below
559+
*</p>
560+
* <pre>
561+
* # Generated by Apache Commons CSV.
562+
* # 2023-08-25T11:37:51.148073200Z
528563
* </pre>
529-
*
530564
* @param headerComments the headerComments which will be printed by the Printer before the actual CSV data.
531565
* @return This instance.
532566
*/
@@ -536,12 +570,27 @@ public Builder setHeaderComments(final Object... headerComments) {
536570
}
537571

538572
/**
539-
* Sets the header comments set to the given values. The comments will be printed first with the provided comment marker set by {@link Builder#setCommentMarker(char)}, before the headers. This setting is ignored by the parser.
540-
*
573+
* Sets the header comments set to the given values. The comments will be printed first, before the headers. This setting is ignored by the parser.
574+
* <p>
575+
* Use {@link Builder#setCommentMarker(char)} or {@link Builder#setCommentMarker(Character)} to set the comment marker to be used with each comment.
576+
* </p>
577+
* <p>
578+
* If comment marker is not set (null) then none of header comments will get printed.
579+
* </p>
580+
* </p>
581+
* For an example, if you use comment marker and header comments as below
582+
* </p>
541583
* <pre>
542-
* Builder.setHeaderComments(&quot;Generated by Apache Commons CSV.&quot;, Instant.now());
584+
* builder.setHeaderComments(&quot;Generated by Apache Commons CSV.&quot;, Instant.now());
585+
* builder.setCommentMarker('#');
586+
* </pre>
587+
*<p>
588+
*you would get header lines printed something similar to below
589+
*</p>
590+
* <pre>
591+
* # Generated by Apache Commons CSV.
592+
* # 2023-08-25T11:37:51.148073200Z
543593
* </pre>
544-
*
545594
* @param headerComments the headerComments which will be printed by the Printer before the actual CSV data.
546595
* @return This instance.
547596
*/

0 commit comments

Comments
 (0)