KeyValuePairWriter.javaSerializes key-value pairs into comma-separated text format — the reverse of KeyValuePairParser. Converts a sequence of write(key, value) calls into a single line like name="ProjectForge",version=8.0,maxUsers=100. 157 lines.
The writer handles proper quoting: string values are always wrapped in double quotes, and any " inside the value is escaped by doubling (" → "") — the same CSV convention that the parser expects. Numbers and dates are written without quotes. The separator character defaults to comma but is configurable via setCsvSeparator().
write() methods — 4 variantswrite(key, long value) — writes as bare number: maxUsers=100. No quoting — safe because numbers contain no special characterswrite(key, Date value) — writes as quoted string in format "yyyy-MM-dd HH:mm:ss.SSS". The date format is configurable via setDateFormat(). Example: lastUpdate="2025-01-24 14:30:00.000"write(key, String s) — writes as quoted string with escape handling. Iterates each character: if the char is ", writes it twice ("" → escaped quote). Example: description="Hallo, das ist ein ""Test""." → this encodes as Hallo, das ist ein "Test". when parsedwrite(key, Object value) — fallback for any type. Uses String.valueOf(value) — no quoting. Suitable for types where toString() produces a safe, non-quoted representation. Not recommended for strings (use the String overload instead — this method doesn't escape quotes)The writeSeparator() method implements the classic first-entry pattern: if this is the first entry, no separator is written; otherwise, a comma is inserted before the current entry. This avoids a trailing comma at the end of the line. The firstEntry boolean is reset with each new line (the parser's EOL triggers a new writer instance or reset).
DEFAULT_SEPARATOR_CHAR = ',' is public — used by KeyValuePairParser to default its pairsSeparatorChar. Both parser and writer default to comma, and both allow changing it. The constant ensures they start with the same default.