[CSV-145] CSVFormat.with* methods clear the header comments
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1641845 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
081b070256
commit
65883aa4d9
|
@ -38,6 +38,9 @@
|
|||
<title>Release Notes</title>
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.1.1" date="20??-MM-DD" description="Feature and bug fix release">
|
||||
<action issue="CSV-145" type="fix" dev="ggregory" due-to="Frank Ulbricht">CSVFormat.with* methods clear the header comments</action>
|
||||
</release>
|
||||
<release version="1.1" date="2014-11-16" description="Feature and bug fix release">
|
||||
<action issue="CSV-140" type="fix" dev="ggregory" due-to="Damjan Jovanovic">QuoteMode.NON_NUMERIC doesn't work with CSVPrinter.printRecords(ResultSet)</action>
|
||||
<action issue="CSV-130" type="fix" dev="ggregory" due-to="Sergei Lebedev">CSVFormat#withHeader doesn't work well with #printComment, add withHeaderComments(String...)</action>
|
||||
|
|
|
@ -804,8 +804,8 @@ public final class CSVFormat implements Serializable {
|
|||
throw new IllegalArgumentException("The comment start marker character cannot be a line break");
|
||||
}
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -822,8 +822,8 @@ public final class CSVFormat implements Serializable {
|
|||
throw new IllegalArgumentException("The delimiter cannot be a line break");
|
||||
}
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -853,7 +853,8 @@ public final class CSVFormat implements Serializable {
|
|||
throw new IllegalArgumentException("The escape character cannot be a line break");
|
||||
}
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escape, ignoreSurroundingSpaces,
|
||||
ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord, allowMissingColumnNames);
|
||||
ignoreEmptyLines, recordSeparator, nullString, headerComments, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -880,8 +881,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withHeader(final String... header) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -948,8 +949,8 @@ public final class CSVFormat implements Serializable {
|
|||
}
|
||||
}
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, labels, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, labels,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -994,8 +995,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNames) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1019,8 +1020,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1044,8 +1045,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1065,8 +1066,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withNullString(final String nullString) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1096,7 +1097,8 @@ public final class CSVFormat implements Serializable {
|
|||
throw new IllegalArgumentException("The quoteChar cannot be a line break");
|
||||
}
|
||||
return new CSVFormat(delimiter, quoteChar, quoteMode, commentMarker, escapeCharacter, ignoreSurroundingSpaces,
|
||||
ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord, allowMissingColumnNames);
|
||||
ignoreEmptyLines, recordSeparator, nullString, headerComments, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1109,8 +1111,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withQuoteMode(final QuoteMode quoteModePolicy) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteModePolicy, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1147,8 +1149,8 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withRecordSeparator(final String recordSeparator) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1174,7 +1176,7 @@ public final class CSVFormat implements Serializable {
|
|||
*/
|
||||
public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
|
||||
return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, null, header, skipHeaderRecord,
|
||||
allowMissingColumnNames);
|
||||
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, headerComments, header,
|
||||
skipHeaderRecord, allowMissingColumnNames);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -579,8 +579,11 @@ public class CSVPrinterTest {
|
|||
|
||||
private CSVPrinter printWithHeaderComments(final StringWriter sw, final Date now, final CSVFormat baseFormat)
|
||||
throws IOException {
|
||||
CSVFormat format = baseFormat.withCommentMarker('#').withHeader("Col1", "Col2");
|
||||
CSVFormat format = baseFormat;
|
||||
// Use withHeaderComments first to test CSV-145
|
||||
format = format.withHeaderComments("Generated by Apache Commons CSV 1.1", now);
|
||||
format = format.withCommentMarker('#');
|
||||
format = format.withHeader("Col1", "Col2");
|
||||
final CSVPrinter csvPrinter = format.print(sw);
|
||||
csvPrinter.printRecord("A", "B");
|
||||
csvPrinter.printRecord("C", "D");
|
||||
|
|
Loading…
Reference in New Issue