com.fasterxml.jackson.dataformat.csv

## Class CsvSchema.Builder

- java.lang.Object
- - com.fasterxml.jackson.dataformat.csv.CsvSchema.Builder

- Enclosing class:
    CsvSchema

      public static class CsvSchema.Builder
      extends Object

  Class used for building `CsvSchema` instances.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `_anyPropertyName` If "any properties" (properties for 'extra' columns; ones not specified in schema) are enabled, they are mapped to this name: leaving it as `null` 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` | `_arrayElementSeparator`
    `protected ArrayList<CsvSchema.Column>` | `_columns`
    `protected char` | `_columnSeparator`
    `protected int` | `_encodingFeatures` Bit-flag for general-purpose on/off features.
    `protected int` | `_escapeChar`
    `protected char[]` | `_lineSeparator`
    `protected char[]` | `_nullValue`
    `protected int` | `_quoteChar`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CsvSchema.Builder()`
    `CsvSchema.Builder(CsvSchema src)` "Copy" constructor which creates builder that has settings of given source schema

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `_checkIndex(int index)`
    `protected void` | `_feature(int feature, boolean state)`
    `CsvSchema.Builder` | `addArrayColumn(String name)`
    `CsvSchema.Builder` | `addArrayColumn(String name, int elementSeparator)` Deprecated. use `addArrayColumn(String, String)` instead
    `CsvSchema.Builder` | `addArrayColumn(String name, String elementSeparator)`
    `CsvSchema.Builder` | `addBooleanColumn(String name)`
    `CsvSchema.Builder` | `addColumn(CsvSchema.Column c)` NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
    `CsvSchema.Builder` | `addColumn(String name)` NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
    `CsvSchema.Builder` | `addColumn(String name, CsvSchema.ColumnType type)` NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
    `CsvSchema.Builder` | `addColumns(Iterable<CsvSchema.Column> cs)` NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
    `CsvSchema.Builder` | `addColumns(Iterable<String> names, CsvSchema.ColumnType type)` NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
    `CsvSchema.Builder` | `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.
    `CsvSchema.Builder` | `addNumberColumn(String name)`
    `CsvSchema` | `build()`
    `CsvSchema.Builder` | `clearColumns()`
    `CsvSchema.Builder` | `disableArrayElementSeparator()`
    `CsvSchema.Builder` | `disableElementSeparator(char c)` Deprecated. use `disableArrayElementSeparator()` instead
    `CsvSchema.Builder` | `disableEscapeChar()` Method for specifying that no escape character is to be used with CSV documents this schema defines.
    `CsvSchema.Builder` | `disableQuoteChar()`
    `Iterator<CsvSchema.Column>` | `getColumns()`
    `boolean` | `hasColumn(String name)` 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).
    `CsvSchema.Builder` | `removeArrayElementSeparator(int index)`
    `CsvSchema.Builder` | `renameColumn(int index, String newName)`
    `CsvSchema.Builder` | `replaceColumn(int index, CsvSchema.Column c)`
    `CsvSchema.Builder` | `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.
    `CsvSchema.Builder` | `setAnyPropertyName(String name)`
    `CsvSchema.Builder` | `setArrayElementSeparator(char c)` Deprecated. use `setArrayElementSeparator(String)` instead
    `void` | `setArrayElementSeparator(int index, char sep)` Deprecated. use `setArrayElementSeparator(String)` instead
    `CsvSchema.Builder` | `setArrayElementSeparator(int index, String sep)`
    `CsvSchema.Builder` | `setArrayElementSeparator(String separator)` Method for specifying character used to separate array element values.
    `CsvSchema.Builder` | `setColumnSeparator(char c)` Method for specifying character used to separate column values.
    `CsvSchema.Builder` | `setColumnType(int index, CsvSchema.ColumnType type)`
    `CsvSchema.Builder` | `setEscapeChar(char c)` Method for specifying character used for optional escaping of characters in quoted String values.
    `CsvSchema.Builder` | `setLineSeparator(char lf)`
    `CsvSchema.Builder` | `setLineSeparator(String lf)`
    `CsvSchema.Builder` | `setNullValue(char[] nvl)`
    `CsvSchema.Builder` | `setNullValue(String nvl)`
    `CsvSchema.Builder` | `setQuoteChar(char c)` Method for specifying character used for optional quoting of values.
    `CsvSchema.Builder` | `setReorderColumns(boolean b)` Use in combination with setUseHeader.
    `CsvSchema.Builder` | `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.
    `CsvSchema.Builder` | `setStrictHeaders(boolean b)` Use in combination with `setUseHeader(boolean)`.
    `CsvSchema.Builder` | `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()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _columns

          protected final ArrayList<CsvSchema.Column> _columns

    - #### _encodingFeatures

          protected int _encodingFeatures

      Bit-flag for general-purpose on/off features.
      Since:
        2.5

    - #### _columnSeparator

          protected char _columnSeparator

    - #### _arrayElementSeparator

          protected String _arrayElementSeparator

    - #### _anyPropertyName

          protected String _anyPropertyName

      If "any properties" (properties for 'extra' columns; ones not specified in schema) are enabled, they are mapped to this name: leaving it as `null` 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 Detail

    - #### CsvSchema.Builder

          public CsvSchema.Builder()

    - #### CsvSchema.Builder

          public CsvSchema.Builder(CsvSchema src)

      "Copy" constructor which creates builder that has settings of given source schema

  - ### Method Detail

    - #### addColumn

          public CsvSchema.Builder addColumn(String name)

      NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.

    - #### addColumn

          public CsvSchema.Builder addColumn(String name,
                                    CsvSchema.ColumnType type)

      NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.

    - #### addColumn

          public CsvSchema.Builder addColumn(CsvSchema.Column c)

      NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.

    - #### addColumns

          public CsvSchema.Builder addColumns(Iterable<CsvSchema.Column> cs)

      NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
      Since:
        2.9

    - #### addColumns

          public CsvSchema.Builder addColumns(Iterable<String> names,
                                     CsvSchema.ColumnType type)

      NOTE: does NOT check for duplicate column names so it is possibly to accidentally add duplicates.
      Since:
        2.9

    - #### addColumnsFrom

          public CsvSchema.Builder 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.
      Since:
        2.9

    - #### addArrayColumn

          public CsvSchema.Builder addArrayColumn(String name)

    - #### addArrayColumn

          @Deprecated
          public CsvSchema.Builder addArrayColumn(String name,
                                                    int elementSeparator)

      Deprecated. use `addArrayColumn(String, String)` instead

    - #### addArrayColumn

          public CsvSchema.Builder addArrayColumn(String name,
                                         String elementSeparator)

      Since:
        2.7

    - #### addNumberColumn

          public CsvSchema.Builder addNumberColumn(String name)

    - #### addBooleanColumn

          public CsvSchema.Builder addBooleanColumn(String name)

    - #### replaceColumn

          public CsvSchema.Builder replaceColumn(int index,
                                        CsvSchema.Column c)

    - #### renameColumn

          public CsvSchema.Builder renameColumn(int index,
                                       String newName)

    - #### setColumnType

          public CsvSchema.Builder setColumnType(int index,
                                        CsvSchema.ColumnType type)

    - #### removeArrayElementSeparator

          public CsvSchema.Builder removeArrayElementSeparator(int index)

    - #### setArrayElementSeparator

          @Deprecated
          public void setArrayElementSeparator(int index,
                                                 char sep)

      Deprecated. use `setArrayElementSeparator(String)` instead

    - #### setArrayElementSeparator

          public CsvSchema.Builder setArrayElementSeparator(int index,
                                                   String sep)

      Since:
        2.7

    - #### setAnyPropertyName

          public CsvSchema.Builder setAnyPropertyName(String name)

    - #### clearColumns

          public CsvSchema.Builder clearColumns()

    - #### size

          public int size()

    - #### getColumns

          public Iterator<CsvSchema.Column> getColumns()

    - #### hasColumn

          public boolean hasColumn(String name)

      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

          public CsvSchema.Builder 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.

    - #### setReorderColumns

          public CsvSchema.Builder setReorderColumns(boolean b)

      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

          public CsvSchema.Builder setStrictHeaders(boolean b)

      Use in combination with `setUseHeader(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

          public CsvSchema.Builder 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.

    - #### setAllowComments

          public CsvSchema.Builder 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.
      Since:
        2.5

    - #### _feature

          protected final void _feature(int feature,
                      boolean state)

    - #### setColumnSeparator

          public CsvSchema.Builder setColumnSeparator(char c)

      Method for specifying character used to separate column values. Default is comma (',').

    - #### setArrayElementSeparator

          @Deprecated
          public CsvSchema.Builder setArrayElementSeparator(char c)

      Deprecated. use `setArrayElementSeparator(String)` instead
      Since:
        2.5

    - #### setArrayElementSeparator

          public CsvSchema.Builder setArrayElementSeparator(String separator)

      Method for specifying character used to separate array element values. Default value is semicolon (";")
      Since:
        2.7

    - #### disableElementSeparator

          @Deprecated
          public CsvSchema.Builder disableElementSeparator(char c)

      Deprecated. use `disableArrayElementSeparator()` instead
      Since:
        2.5

    - #### disableArrayElementSeparator

          public CsvSchema.Builder disableArrayElementSeparator()

      Since:
        2.7

    - #### setQuoteChar

          public CsvSchema.Builder setQuoteChar(char c)

      Method for specifying character used for optional quoting of values. Default is double-quote ('"').

    - #### disableQuoteChar

          public CsvSchema.Builder disableQuoteChar()

      Since:
        2.4

    - #### setEscapeChar

          public CsvSchema.Builder setEscapeChar(char c)

      Method for specifying character used for optional escaping of characters in quoted String values. Default is "not used", meaning that no escaping used.

    - #### disableEscapeChar

          public CsvSchema.Builder disableEscapeChar()

      Method for specifying that no escape character is to be used with CSV documents this schema defines.

    - #### setLineSeparator

          public CsvSchema.Builder setLineSeparator(String lf)

    - #### setLineSeparator

          public CsvSchema.Builder setLineSeparator(char lf)

    - #### setNullValue

          public CsvSchema.Builder setNullValue(String nvl)

    - #### setNullValue

          public CsvSchema.Builder setNullValue(char[] nvl)

    - #### build

          public CsvSchema build()

    - #### _checkIndex

          protected void _checkIndex(int index)

Copyright © 2017 FasterXML. All rights reserved.