Package com.veeva.vault.sdk.api.csv
Interface CsvWriteParameters
public interface CsvWriteParameters
Parameters that define the format of the CSV being written.
The default parameters will write CSVs that follow these guidelines:
- Values are separated by commas.
- Rows are separated by line endings. Supported line endings are defined in
LineEnding
. - Values that contain commas or line endings must be surrounded by double-quotes. For example,
"Address, Street"
. - Values that contain double-quotes or escapes must be escaped. For example, pre-pending the character with
\
. - Dates are in the ISO-8601 format. For example,
2001-02-03
. - DateTimes are in the ISO-8601 format. For example,
2001-02-03T04:05:06.007Z
.
String
before being written (e.g. by using LocalDate.format(DateTimeFormatter)
).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
Character that can be provided tosetEscape(char)
if no escapes should be written before individual values.static final char
Character that can be passed intosetQuote(char)
if no quotes should be written around individual values. -
Method Summary
Modifier and TypeMethodDescriptionsetEscape
(char escape) Sets the character used to escape special characters (e.g.setHeaders
(List<String> headers) Sets the CSV headers (i.e.setLineEnding
(LineEnding lineEnding) Sets theLineEnding
that separates individual rows.setQuote
(char quote) Sets the character used to surround individual values.setSeparator
(char separator) Sets the character that separates values.
-
Field Details
-
NO_QUOTES_CHARACTER
static final char NO_QUOTES_CHARACTERCharacter that can be passed intosetQuote(char)
if no quotes should be written around individual values.- See Also:
-
NO_ESCAPE_CHARACTER
static final char NO_ESCAPE_CHARACTERCharacter that can be provided tosetEscape(char)
if no escapes should be written before individual values.- See Also:
-
-
Method Details
-
setHeaders
Sets the CSV headers (i.e. column names) for the CSV being written. If not set, the CSV will be written without headers.Not setting headers has the implication that certain methods that accept column names (e.g.
RowBuilder.setValueByName(String, Object)
) will throw exceptions.- Parameters:
headers
- a list of headers for the CSV. Cannot be null or contain null/duplicate values.- Returns:
- the current write parameters
-
setSeparator
Sets the character that separates values. If not set, the separator character defaults to','
.For example, if the separator character is
','
, then when writing the values "ABC" and "DEF" the output would be"ABC,DEF"
.- Parameters:
separator
- the separator char- Returns:
- the current write parameters
-
setEscape
Sets the character used to escape special characters (e.g. quote characters, escape characters). If not set, the escape character defaults to'\'
.During writes, this character will be written before any special character that is contained in an individual value.
- Parameters:
escape
- the escape char- Returns:
- the current write parameters
-
setQuote
Sets the character used to surround individual values. If not set, the quote character defaults to'"'
.If no quotes should be written, this method can be called with
NO_QUOTES_CHARACTER
.- Parameters:
quote
- the quote character- Returns:
- the current write parameters
-
setLineEnding
Sets theLineEnding
that separates individual rows. If not set, the line endings will default toLineEnding.LF
.During writes, this line ending will be appended to every row.
- Parameters:
lineEnding
- the line ending. Cannot be null.- Returns:
- the current write parameters
-