@@ -270,32 +270,36 @@ public static Builder create(final CSVFormat csvFormat) {
270270
271271 private boolean trim ;
272272
273+ /** The maximum number of rows to process, excluding the header row. */
274+ private long maxRows ;
275+
273276 private Builder () {
274277 // empty
275278 }
276279
277280 private Builder (final CSVFormat csvFormat ) {
278- this .delimiter = csvFormat .delimiter ;
279- this .quoteCharacter = csvFormat .quoteCharacter ;
280- this .quoteMode = csvFormat .quoteMode ;
281+ this .allowMissingColumnNames = csvFormat .allowMissingColumnNames ;
282+ this .autoFlush = csvFormat .autoFlush ;
281283 this .commentMarker = csvFormat .commentMarker ;
284+ this .delimiter = csvFormat .delimiter ;
285+ this .duplicateHeaderMode = csvFormat .duplicateHeaderMode ;
282286 this .escapeCharacter = csvFormat .escapeCharacter ;
283- this .ignoreSurroundingSpaces = csvFormat .ignoreSurroundingSpaces ;
284- this .allowMissingColumnNames = csvFormat .allowMissingColumnNames ;
285- this .ignoreEmptyLines = csvFormat .ignoreEmptyLines ;
286- this .recordSeparator = csvFormat .recordSeparator ;
287- this .nullString = csvFormat .nullString ;
288287 this .headerComments = csvFormat .headerComments ;
289288 this .headers = csvFormat .headers ;
290- this .skipHeaderRecord = csvFormat .skipHeaderRecord ;
289+ this .ignoreEmptyLines = csvFormat .ignoreEmptyLines ;
291290 this .ignoreHeaderCase = csvFormat .ignoreHeaderCase ;
291+ this .ignoreSurroundingSpaces = csvFormat .ignoreSurroundingSpaces ;
292292 this .lenientEof = csvFormat .lenientEof ;
293+ this .maxRows = csvFormat .maxRows ;
294+ this .nullString = csvFormat .nullString ;
295+ this .quoteCharacter = csvFormat .quoteCharacter ;
296+ this .quoteMode = csvFormat .quoteMode ;
297+ this .quotedNullString = csvFormat .quotedNullString ;
298+ this .recordSeparator = csvFormat .recordSeparator ;
299+ this .skipHeaderRecord = csvFormat .skipHeaderRecord ;
293300 this .trailingData = csvFormat .trailingData ;
294301 this .trailingDelimiter = csvFormat .trailingDelimiter ;
295302 this .trim = csvFormat .trim ;
296- this .autoFlush = csvFormat .autoFlush ;
297- this .quotedNullString = csvFormat .quotedNullString ;
298- this .duplicateHeaderMode = csvFormat .duplicateHeaderMode ;
299303 }
300304
301305 /**
@@ -738,6 +742,18 @@ public Builder setLenientEof(final boolean lenientEof) {
738742 return this ;
739743 }
740744
745+ /**
746+ * Sets the maximum number of rows to process, excluding the header row.
747+ *
748+ * @param maxRows the maximum number of rows to process, excluding the header row.
749+ * @return This instance.
750+ * @since 1.14.0
751+ */
752+ public Builder setMaxRows (final long maxRows ) {
753+ this .maxRows = maxRows ;
754+ return this ;
755+ }
756+
741757 /**
742758 * Sets the String to convert to and from {@code null}. No substitution occurs if {@code null}.
743759 *
@@ -857,6 +873,7 @@ public Builder setTrailingDelimiter(final boolean trailingDelimiter) {
857873 return this ;
858874 }
859875
876+
860877 /**
861878 * Sets whether to trim leading and trailing blanks.
862879 *
@@ -1580,28 +1597,32 @@ public static CSVFormat valueOf(final String format) {
15801597 /** Whether to trim leading and trailing blanks. */
15811598 private final boolean trim ;
15821599
1600+ /** The maximum number of rows to process, excluding the header row. */
1601+ private final long maxRows ;
1602+
15831603 private CSVFormat (final Builder builder ) {
1584- this .delimiter = builder .delimiter ;
1585- this .quoteCharacter = builder .quoteCharacter ;
1586- this .quoteMode = builder .quoteMode ;
1604+ this .allowMissingColumnNames = builder .allowMissingColumnNames ;
1605+ this .autoFlush = builder .autoFlush ;
15871606 this .commentMarker = builder .commentMarker ;
1607+ this .delimiter = builder .delimiter ;
1608+ this .duplicateHeaderMode = builder .duplicateHeaderMode ;
15881609 this .escapeCharacter = builder .escapeCharacter ;
1589- this .ignoreSurroundingSpaces = builder .ignoreSurroundingSpaces ;
1590- this .allowMissingColumnNames = builder .allowMissingColumnNames ;
1591- this .ignoreEmptyLines = builder .ignoreEmptyLines ;
1592- this .recordSeparator = builder .recordSeparator ;
1593- this .nullString = builder .nullString ;
15941610 this .headerComments = builder .headerComments ;
15951611 this .headers = builder .headers ;
1596- this .skipHeaderRecord = builder .skipHeaderRecord ;
1612+ this .ignoreEmptyLines = builder .ignoreEmptyLines ;
15971613 this .ignoreHeaderCase = builder .ignoreHeaderCase ;
1614+ this .ignoreSurroundingSpaces = builder .ignoreSurroundingSpaces ;
15981615 this .lenientEof = builder .lenientEof ;
1616+ this .maxRows = builder .maxRows ;
1617+ this .nullString = builder .nullString ;
1618+ this .quoteCharacter = builder .quoteCharacter ;
1619+ this .quoteMode = builder .quoteMode ;
1620+ this .quotedNullString = builder .quotedNullString ;
1621+ this .recordSeparator = builder .recordSeparator ;
1622+ this .skipHeaderRecord = builder .skipHeaderRecord ;
15991623 this .trailingData = builder .trailingData ;
16001624 this .trailingDelimiter = builder .trailingDelimiter ;
16011625 this .trim = builder .trim ;
1602- this .autoFlush = builder .autoFlush ;
1603- this .quotedNullString = builder .quotedNullString ;
1604- this .duplicateHeaderMode = builder .duplicateHeaderMode ;
16051626 validate ();
16061627 }
16071628
@@ -1898,6 +1919,16 @@ public boolean getLenientEof() {
18981919 return lenientEof ;
18991920 }
19001921
1922+ /**
1923+ * Gets the maximum number of rows to process, excluding the header row.
1924+ *
1925+ * @return The maximum number of rows to process, excluding the header row.
1926+ * @since 1.14.0
1927+ */
1928+ public long getMaxRows () {
1929+ return maxRows ;
1930+ }
1931+
19011932 /**
19021933 * Gets the String to convert to and from {@code null}.
19031934 * <ul>
@@ -1982,10 +2013,9 @@ public int hashCode() {
19822013 int result = 1 ;
19832014 result = prime * result + Arrays .hashCode (headerComments );
19842015 result = prime * result + Arrays .hashCode (headers );
1985- result = prime * result + Objects .hash (allowMissingColumnNames , autoFlush , commentMarker , delimiter , duplicateHeaderMode , escapeCharacter ,
2016+ return prime * result + Objects .hash (allowMissingColumnNames , autoFlush , commentMarker , delimiter , duplicateHeaderMode , escapeCharacter ,
19862017 ignoreEmptyLines , ignoreHeaderCase , ignoreSurroundingSpaces , lenientEof , nullString , quoteCharacter , quoteMode , quotedNullString ,
19872018 recordSeparator , skipHeaderRecord , trailingData , trailingDelimiter , trim );
1988- return result ;
19892019 }
19902020
19912021 /**
0 commit comments