Skip to content

Commit

Permalink
documentation enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
osiegmar committed Apr 28, 2024
1 parent 8419a80 commit 69d4821
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add `writeRecord()` to `CsvWriter` to allow writing records field by field
- Allow overwriting the limits of 16K fields per record and 16M characters per field (#104); Thanks to [@Obolrom](https://github.com/Obolrom)!

## [3.1.0] - 2024-03-09
### Added
Expand Down
22 changes: 14 additions & 8 deletions lib/src/main/java/de/siegmar/fastcsv/util/Limits.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
/**
* The {@code Limits} class defines the maximum limits for various fields and records in a CSV file.
* <p>
* Limits can be overridden by setting system properties.
* Example use:
* <pre>{@code
* System.setProperty("fastcsv.max.field.size", "1024");
* }</pre>
* {@snippet :
* System.setProperty("fastcsv.max.field.size", "8388608");
* System.setProperty("fastcsv.max.field.count", "8192");
*}
* <p>
* Or using VM options:
* <pre>{@code
* -Dfastcsv.max.field.count=1024
* }</pre>
* <pre>{@code -Dfastcsv.max.field.count=8388608 -Dfastcsv.max.field.count=8192}</pre>
*/
public final class Limits {

/**
* The {@code MAX_FIELD_SIZE} constant defines the maximum size for a single field in a CSV file.
* The value is set to 16,777,216 characters (16 to 64 MiB depending on the circumstance of multibyte character
* utilization).
* <p>
* The default value can be overridden by setting the system property {@code fastcsv.max.field.size} (e.g., using
* {@code -Dfastcsv.max.field.size=8388608}).
*/
public static final int MAX_FIELD_SIZE = getIntProperty("fastcsv.max.field.size", 16 * 1024 * 1024);

/**
* The {@code MAX_FIELDS_SIZE} constant defines the maximum number of fields per record.
* The value is set to 16,384.
* <p>
* The default value can be overridden by setting the system property {@code fastcsv.max.field.count} (e.g., using
* {@code -Dfastcsv.max.field.count=8192}).
*/
public static final int MAX_FIELD_COUNT = getIntProperty("fastcsv.max.field.count", 16 * 1024);

Expand All @@ -38,10 +44,10 @@ private Limits() {
}

/**
* Retrieves the system property value if presented, otherwise default value is returned.
* Retrieves the system property value if presented, otherwise the default value is returned.
* If the property cannot be parsed as an integer, an {@code IllegalArgumentException} is thrown.
*
* @param key The system property key.
* @param key The system property key.
* @param defaultValue The default value to use if the system property is not set or is invalid.
* @return The system property value as an integer or the default value if the property is not set or is invalid.
* @throws IllegalArgumentException If the system property value cannot be parsed as an integer.
Expand Down

0 comments on commit 69d4821

Please sign in to comment.