Class CsvSchema.Builder
java.lang.Object
com.fasterxml.jackson.dataformat.csv.CsvSchema.Builder
- Enclosing class:
- CsvSchema
Class used for building
CsvSchema
instances.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
If "any properties" (properties for 'extra' columns; ones not specified in schema) are enabled, they are mapped to this name: leaving it asnull
disables use of "any properties" (and they are either ignored, or an exception is thrown, depending on other settings); setting it to a non-null String value will expose all extra properties under one specified name.protected String
protected final ArrayList<CsvSchema.Column>
protected char
protected int
Bit-flag for general-purpose on/off features.protected int
protected char[]
protected char[]
protected int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_checkIndex
(int index) protected final void
_feature
(int feature, boolean state) addArrayColumn
(String name) addArrayColumn
(String name, int elementSeparator) Deprecated.addArrayColumn
(String name, String elementSeparator) addBooleanColumn
(String name) NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.addColumn
(String name, CsvSchema.ColumnType type) NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.addColumns
(Iterable<String> names, CsvSchema.ColumnType type) NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.addColumnsFrom
(CsvSchema schema) NOTE: unlike many other add methods, this method DOES check for, and discard, possible duplicate columns: that is, if this builder already has a column with same name as column to be added, existing column is retained and new column ignored.addNumberColumn
(String name) build()
disableElementSeparator
(char c) Deprecated.usedisableArrayElementSeparator()
insteadMethod for specifying that no escape character is to be used with CSV documents this schema defines.boolean
NOTE: this method requires linear scan over existing columns so it may be more efficient to use other types of lookups if available (for example,CsvSchema.column(String)
has a hash lookup to use).removeArrayElementSeparator
(int index) renameColumn
(int index, String newName) replaceColumn
(int index, CsvSchema.Column c) setAllowComments
(boolean b) Method for specifying whether Schema should indicate that "hash comments" (lines where the first non-whitespace character is '#') are allowed; if so, they will be skipped without processing.setAnyPropertyName
(String name) setArrayElementSeparator
(char c) Deprecated.usesetArrayElementSeparator(String)
insteadvoid
setArrayElementSeparator
(int index, char sep) Deprecated.usesetArrayElementSeparator(String)
insteadsetArrayElementSeparator
(int index, String sep) setArrayElementSeparator
(String separator) Method for specifying character used to separate array element values.setColumnSeparator
(char c) Method for specifying character used to separate column values.setColumnType
(int index, CsvSchema.ColumnType type) setEscapeChar
(char c) Method for specifying character used for optional escaping of characters in quoted String values.setLineSeparator
(char lf) setNullValue
(char[] nvl) setNullValue
(String nvl) setQuoteChar
(char c) Method for specifying character used for optional quoting of values.setReorderColumns
(boolean b) Use in combination with setUseHeader.setSkipFirstDataRow
(boolean b) Method for specifying whether Schema should indicate that the first line that is not a header (if header handling enabled) should be skipped in its entirety.setStrictHeaders
(boolean b) Use in combination withsetUseHeader(boolean)
.setUseHeader
(boolean b) Method for specifying whether Schema should indicate that a header line (first row that contains column names) is to be used for reading and writing or not.int
size()
-
Field Details
-
_columns
-
_encodingFeatures
protected int _encodingFeaturesBit-flag for general-purpose on/off features.- Since:
- 2.5
-
_columnSeparator
protected char _columnSeparator -
_arrayElementSeparator
-
_anyPropertyName
If "any properties" (properties for 'extra' columns; ones not specified in schema) are enabled, they are mapped to this name: leaving it asnull
disables use of "any properties" (and they are either ignored, or an exception is thrown, depending on other settings); setting it to a non-null String value will expose all extra properties under one specified name.- Since:
- 2.7
-
_quoteChar
protected int _quoteChar -
_escapeChar
protected int _escapeChar -
_lineSeparator
protected char[] _lineSeparator -
_nullValue
protected char[] _nullValue- Since:
- 2.5
-
-
Constructor Details
-
Builder
public Builder() -
Builder
"Copy" constructor which creates builder that has settings of given source schema
-
-
Method Details
-
addColumn
NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates. -
addColumn
NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates. -
addColumn
NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates. -
addColumns
NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.- Since:
- 2.9
-
addColumns
NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.- Since:
- 2.9
-
addColumnsFrom
NOTE: unlike many other add methods, this method DOES check for, and discard, possible duplicate columns: that is, if this builder already has a column with same name as column to be added, existing column is retained and new column ignored.- Since:
- 2.9
-
addArrayColumn
-
addArrayColumn
Deprecated.useaddArrayColumn(String, String)
instead -
addArrayColumn
- Since:
- 2.7
-
addNumberColumn
-
addBooleanColumn
-
replaceColumn
-
renameColumn
-
setColumnType
-
removeArrayElementSeparator
-
setArrayElementSeparator
Deprecated.usesetArrayElementSeparator(String)
instead -
setArrayElementSeparator
- Since:
- 2.7
-
setAnyPropertyName
-
clearColumns
-
size
public int size() -
getColumns
-
hasColumn
NOTE: this method requires linear scan over existing columns so it may be more efficient to use other types of lookups if available (for example,
CsvSchema.column(String)
has a hash lookup to use).- Since:
- 2.9
-
setUseHeader
Method for specifying whether Schema should indicate that a header line (first row that contains column names) is to be used for reading and writing or not. -
setReorderColumns
Use in combination with setUseHeader. When use header flag is is set, this setting will reorder the columns defined in this schema to match the order set by the header.- Parameters:
b
- Enable / Disable this setting- Returns:
- This Builder instance
- Since:
- 2.7
-
setStrictHeaders
Use in combination withsetUseHeader(boolean)
. When `strict-headers` is set, encoder will ensure the headers are in the order of the schema; if order differs, an exception is thrown.- Parameters:
b
- Enable / Disable this setting- Returns:
- This Builder instance
- Since:
- 2.7
-
setSkipFirstDataRow
Method for specifying whether Schema should indicate that the first line that is not a header (if header handling enabled) should be skipped in its entirety. -
setAllowComments
Method for specifying whether Schema should indicate that "hash comments" (lines where the first non-whitespace character is '#') are allowed; if so, they will be skipped without processing.- Since:
- 2.5
-
_feature
protected final void _feature(int feature, boolean state) -
setColumnSeparator
Method for specifying character used to separate column values. Default is comma (','). -
setArrayElementSeparator
Deprecated.usesetArrayElementSeparator(String)
instead- Since:
- 2.5
-
setArrayElementSeparator
Method for specifying character used to separate array element values. Default value is semicolon (";")- Since:
- 2.7
-
disableElementSeparator
Deprecated.usedisableArrayElementSeparator()
instead- Since:
- 2.5
-
disableArrayElementSeparator
- Since:
- 2.7
-
setQuoteChar
Method for specifying character used for optional quoting of values. Default is double-quote ('"'). -
disableQuoteChar
- Since:
- 2.4
-
setEscapeChar
Method for specifying character used for optional escaping of characters in quoted String values. Default is "not used", meaning that no escaping used. -
disableEscapeChar
Method for specifying that no escape character is to be used with CSV documents this schema defines. -
setLineSeparator
-
setLineSeparator
-
setNullValue
-
setNullValue
-
build
-
_checkIndex
protected void _checkIndex(int index)
-
addArrayColumn(String, String)
instead