@@ -242,7 +242,7 @@ public CSVFormat getFormat() {
242242 * @see Predefined#Default
243243 */
244244 public static final CSVFormat DEFAULT = new CSVFormat (COMMA , DOUBLE_QUOTE_CHAR , null , null , null , false , true , CRLF ,
245- null , null , null , false , false , false , false , false );
245+ null , null , null , false , false , false , false , false , false );
246246
247247 /**
248248 * Excel file format (using a comma as the value delimiter). Note that the actual value delimiter used by Excel is
@@ -537,7 +537,7 @@ private static boolean isLineBreak(final Character c) {
537537 */
538538 public static CSVFormat newFormat (final char delimiter ) {
539539 return new CSVFormat (delimiter , null , null , null , null , false , false , null , null , null , null , false , false ,
540- false , false , false );
540+ false , false , false , false );
541541 }
542542
543543 /**
@@ -570,6 +570,8 @@ public static CSVFormat valueOf(final String format) {
570570
571571 private final boolean ignoreSurroundingSpaces ; // Should leading/trailing spaces be ignored around values?
572572
573+ private final boolean mutableRecords ;
574+
573575 private final String nullString ; // the string to be used for null values
574576
575577 private final Character quoteCharacter ; // null if quoting is disabled
@@ -619,6 +621,7 @@ public static CSVFormat valueOf(final String format) {
619621 * TODO
620622 * @param trailingDelimiter
621623 * TODO
624+ * @param mutableRecords TODO
622625 * @throws IllegalArgumentException
623626 * if the delimiter is a line break character
624627 */
@@ -627,7 +630,7 @@ private CSVFormat(final char delimiter, final Character quoteChar, final QuoteMo
627630 final boolean ignoreEmptyLines , final String recordSeparator , final String nullString ,
628631 final Object [] headerComments , final String [] header , final boolean skipHeaderRecord ,
629632 final boolean allowMissingColumnNames , final boolean ignoreHeaderCase , final boolean trim ,
630- final boolean trailingDelimiter ) {
633+ final boolean trailingDelimiter , boolean mutableRecords ) {
631634 this .delimiter = delimiter ;
632635 this .quoteCharacter = quoteChar ;
633636 this .quoteMode = quoteMode ;
@@ -644,6 +647,7 @@ private CSVFormat(final char delimiter, final Character quoteChar, final QuoteMo
644647 this .ignoreHeaderCase = ignoreHeaderCase ;
645648 this .trailingDelimiter = trailingDelimiter ;
646649 this .trim = trim ;
650+ this .mutableRecords = mutableRecords ;
647651 validate ();
648652 }
649653
@@ -927,6 +931,10 @@ public boolean isEscapeCharacterSet() {
927931 return escapeCharacter != null ;
928932 }
929933
934+ public boolean isMutableRecords () {
935+ return mutableRecords ;
936+ }
937+
930938 /**
931939 * Returns whether a nullString has been defined.
932940 *
@@ -1431,7 +1439,7 @@ public CSVFormat withAllowMissingColumnNames() {
14311439 public CSVFormat withAllowMissingColumnNames (final boolean allowMissingColumnNames ) {
14321440 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
14331441 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1434- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1442+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
14351443 }
14361444
14371445 /**
@@ -1466,7 +1474,7 @@ public CSVFormat withCommentMarker(final Character commentMarker) {
14661474 }
14671475 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
14681476 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1469- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1477+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
14701478 }
14711479
14721480 /**
@@ -1484,7 +1492,7 @@ public CSVFormat withDelimiter(final char delimiter) {
14841492 }
14851493 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
14861494 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1487- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1495+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
14881496 }
14891497
14901498 /**
@@ -1515,7 +1523,7 @@ public CSVFormat withEscape(final Character escape) {
15151523 }
15161524 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escape , ignoreSurroundingSpaces ,
15171525 ignoreEmptyLines , recordSeparator , nullString , headerComments , header , skipHeaderRecord ,
1518- allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1526+ allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
15191527 }
15201528
15211529 /**
@@ -1670,7 +1678,7 @@ public CSVFormat withHeader(final ResultSetMetaData metaData) throws SQLExceptio
16701678 public CSVFormat withHeader (final String ... header ) {
16711679 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
16721680 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1673- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1681+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
16741682 }
16751683
16761684 /**
@@ -1691,7 +1699,7 @@ public CSVFormat withHeader(final String... header) {
16911699 public CSVFormat withHeaderComments (final Object ... headerComments ) {
16921700 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
16931701 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1694- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1702+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
16951703 }
16961704
16971705 /**
@@ -1716,7 +1724,7 @@ public CSVFormat withIgnoreEmptyLines() {
17161724 public CSVFormat withIgnoreEmptyLines (final boolean ignoreEmptyLines ) {
17171725 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
17181726 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1719- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1727+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
17201728 }
17211729
17221730 /**
@@ -1742,7 +1750,7 @@ public CSVFormat withIgnoreHeaderCase() {
17421750 public CSVFormat withIgnoreHeaderCase (final boolean ignoreHeaderCase ) {
17431751 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
17441752 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1745- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1753+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
17461754 }
17471755
17481756 /**
@@ -1767,7 +1775,25 @@ public CSVFormat withIgnoreSurroundingSpaces() {
17671775 public CSVFormat withIgnoreSurroundingSpaces (final boolean ignoreSurroundingSpaces ) {
17681776 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
17691777 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1770- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1778+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
1779+ }
1780+
1781+ /**
1782+ * Returns a new {@code CSVFormat} with whether to generate CSVRecord or CSVMutableRecord.
1783+ * <ul>
1784+ * <li><strong>Reading:</strong> Whether to generate CSVRecord or CSVMutableRecord.</li>
1785+ * <li><strong>Writing:</strong> No effect.</li>
1786+ * </ul>
1787+ *
1788+ * @param mutableRecords
1789+ * whether to generate CSVRecord or CSVMutableRecord
1790+ *
1791+ * @return A new CSVFormat that is equal to this but with the specified null conversion string.
1792+ */
1793+ public CSVFormat withMutableRecords (final boolean mutableRecords ) {
1794+ return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
1795+ ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1796+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
17711797 }
17721798
17731799 /**
@@ -1786,7 +1812,7 @@ public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpac
17861812 public CSVFormat withNullString (final String nullString ) {
17871813 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
17881814 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1789- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1815+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
17901816 }
17911817
17921818 /**
@@ -1817,7 +1843,7 @@ public CSVFormat withQuote(final Character quoteChar) {
18171843 }
18181844 return new CSVFormat (delimiter , quoteChar , quoteMode , commentMarker , escapeCharacter , ignoreSurroundingSpaces ,
18191845 ignoreEmptyLines , recordSeparator , nullString , headerComments , header , skipHeaderRecord ,
1820- allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1846+ allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
18211847 }
18221848
18231849 /**
@@ -1831,7 +1857,7 @@ public CSVFormat withQuote(final Character quoteChar) {
18311857 public CSVFormat withQuoteMode (final QuoteMode quoteModePolicy ) {
18321858 return new CSVFormat (delimiter , quoteCharacter , quoteModePolicy , commentMarker , escapeCharacter ,
18331859 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1834- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1860+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
18351861 }
18361862
18371863 /**
@@ -1869,7 +1895,7 @@ public CSVFormat withRecordSeparator(final char recordSeparator) {
18691895 public CSVFormat withRecordSeparator (final String recordSeparator ) {
18701896 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
18711897 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1872- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1898+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
18731899 }
18741900
18751901 /**
@@ -1896,7 +1922,7 @@ public CSVFormat withSkipHeaderRecord() {
18961922 public CSVFormat withSkipHeaderRecord (final boolean skipHeaderRecord ) {
18971923 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
18981924 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1899- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1925+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
19001926 }
19011927
19021928 /**
@@ -1921,7 +1947,7 @@ public CSVFormat withTrailingDelimiter() {
19211947 public CSVFormat withTrailingDelimiter (final boolean trailingDelimiter ) {
19221948 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
19231949 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1924- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1950+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
19251951 }
19261952
19271953 /**
@@ -1946,6 +1972,7 @@ public CSVFormat withTrim() {
19461972 public CSVFormat withTrim (final boolean trim ) {
19471973 return new CSVFormat (delimiter , quoteCharacter , quoteMode , commentMarker , escapeCharacter ,
19481974 ignoreSurroundingSpaces , ignoreEmptyLines , recordSeparator , nullString , headerComments , header ,
1949- skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter );
1975+ skipHeaderRecord , allowMissingColumnNames , ignoreHeaderCase , trim , trailingDelimiter , mutableRecords );
19501976 }
1977+
19511978}
0 commit comments