Class CsvConfig
java.lang.Object
cloud.opencode.base.csv.CsvConfig
CSV Configuration - Immutable configuration for CSV parsing and writing
CSV配置 - CSV解析和写入的不可变配置
Holds all parameters that control CSV processing behavior, including delimiters, quoting, character set, size limits, and security options. All instances are immutable and thread-safe.
持有控制CSV处理行为的所有参数,包括分隔符、引用、字符集、大小限制和安全选项。 所有实例都是不可变且线程安全的。
Features | 主要功能:
- RFC 4180 defaults - RFC 4180 默认值
- Builder pattern for fluent construction - Builder模式流式构建
- Configurable size limits for DoS protection - 可配置大小限制防止DoS
- Formula injection protection toggle - 公式注入保护开关
Usage Examples | 使用示例:
// Use defaults
CsvConfig config = CsvConfig.DEFAULT;
// Custom config
CsvConfig config = CsvConfig.builder()
.delimiter(';')
.charset(StandardCharsets.ISO_8859_1)
.trimFields(true)
.formulaProtection(true)
.build();
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Null-safe: Yes (constructor validates) - 空值安全: 是(构造时校验)
- Since:
- JDK 25, opencode-base-csv V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for CsvConfig CsvConfig构建器 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CsvConfigDefault configuration instance with RFC 4180 settings 使用RFC 4180设置的默认配置实例static final charDefault delimiter: comma per RFC 4180 | 默认分隔符:逗号(RFC 4180)static final charDefault escape character: double quote per RFC 4180 | 默认转义字符:双引号(RFC 4180)static final StringDefault line separator: CRLF per RFC 4180 | 默认行分隔符:CRLF(RFC 4180)static final intDefault max columns | 默认最大列数static final intDefault max field size: 1 MB | 默认最大字段大小:1 MBstatic final intDefault max rows | 默认最大行数static final charDefault quote character: double quote per RFC 4180 | 默认引用字符:双引号(RFC 4180) -
Method Summary
Modifier and TypeMethodDescriptionstatic CsvConfig.Builderbuilder()Creates a new builder 创建新的构建器charset()Gets the character set 获取字符集charGets the field delimiter character 获取字段分隔符字符booleancharGets the escape character 获取转义字符booleanReturns whether formula injection protection is enabled 返回是否启用公式注入保护inthashCode()booleanReturns whether the CSV has a header row 返回CSV是否有标题行Gets the line separator 获取行分隔符intGets the maximum number of columns allowed 获取允许的最大列数intGets the maximum field size in bytes 获取最大字段大小(字节)intmaxRows()Gets the maximum number of rows allowed 获取允许的最大行数Gets the string to write for null values 获取null值的写入字符串charGets the quote character 获取引用字符booleanReturns whether empty rows should be skipped 返回是否应跳过空行toString()booleanReturns whether fields should be trimmed 返回字段是否应被修剪
-
Field Details
-
DEFAULT_DELIMITER
public static final char DEFAULT_DELIMITERDefault delimiter: comma per RFC 4180 | 默认分隔符:逗号(RFC 4180)- See Also:
-
DEFAULT_QUOTE_CHAR
public static final char DEFAULT_QUOTE_CHARDefault quote character: double quote per RFC 4180 | 默认引用字符:双引号(RFC 4180)- See Also:
-
DEFAULT_ESCAPE_CHAR
public static final char DEFAULT_ESCAPE_CHARDefault escape character: double quote per RFC 4180 | 默认转义字符:双引号(RFC 4180)- See Also:
-
DEFAULT_LINE_SEPARATOR
Default line separator: CRLF per RFC 4180 | 默认行分隔符:CRLF(RFC 4180)- See Also:
-
DEFAULT_MAX_ROWS
public static final int DEFAULT_MAX_ROWSDefault max rows | 默认最大行数- See Also:
-
DEFAULT_MAX_COLUMNS
public static final int DEFAULT_MAX_COLUMNSDefault max columns | 默认最大列数- See Also:
-
DEFAULT_MAX_FIELD_SIZE
public static final int DEFAULT_MAX_FIELD_SIZEDefault max field size: 1 MB | 默认最大字段大小:1 MB- See Also:
-
DEFAULT
Default configuration instance with RFC 4180 settings 使用RFC 4180设置的默认配置实例
-
-
Method Details
-
delimiter
public char delimiter()Gets the field delimiter character 获取字段分隔符字符- Returns:
- the delimiter | 分隔符
-
quoteChar
public char quoteChar()Gets the quote character 获取引用字符- Returns:
- the quote character | 引用字符
-
escapeChar
public char escapeChar()Gets the escape character 获取转义字符- Returns:
- the escape character | 转义字符
-
lineSeparator
-
charset
-
hasHeader
public boolean hasHeader()Returns whether the CSV has a header row 返回CSV是否有标题行- Returns:
- true if header present | 如果有标题行返回true
-
trimFields
public boolean trimFields()Returns whether fields should be trimmed 返回字段是否应被修剪- Returns:
- true if trimming enabled | 如果启用修剪返回true
-
skipEmptyRows
public boolean skipEmptyRows()Returns whether empty rows should be skipped 返回是否应跳过空行- Returns:
- true if skipping empty rows | 如果跳过空行返回true
-
maxRows
public int maxRows()Gets the maximum number of rows allowed 获取允许的最大行数- Returns:
- the max rows | 最大行数
-
maxColumns
public int maxColumns()Gets the maximum number of columns allowed 获取允许的最大列数- Returns:
- the max columns | 最大列数
-
maxFieldSize
public int maxFieldSize()Gets the maximum field size in bytes 获取最大字段大小(字节)- Returns:
- the max field size | 最大字段大小
-
formulaProtection
public boolean formulaProtection()Returns whether formula injection protection is enabled 返回是否启用公式注入保护- Returns:
- true if protection enabled | 如果启用保护返回true
-
nullString
Gets the string to write for null values 获取null值的写入字符串- Returns:
- the null string | null值字符串
-
builder
Creates a new builder 创建新的构建器- Returns:
- a new Builder instance | 新的Builder实例
-
equals
-
hashCode
-
toString
-