Class CsvFormat.Builder

  • Enclosing class:
    CsvFormat

    public static final class CsvFormat.Builder
    extends Object
    • Method Detail

      • allowDoubleQuoteEscape

        public CsvFormat.Builder allowDoubleQuoteEscape​(boolean allowDoubleQuoteEscape)
        Whether to allow double quote escape. If set to true, a quote character can be escaped by repeating it.
        Parameters:
        allowDoubleQuoteEscape - Whether to allow double quote escape.
        Returns:
        This builder for chaining method calls.
      • build

        public CsvFormat build()
        Builds the CsvFormat instance. Modifying the builder after calling this method has no effect on the returned instance.
        Returns:
        The CsvFormat instance.
      • cellFilter

        public CsvFormat.Builder cellFilter​(Predicate<String> cellFilter)
        Sets the cell filter that is applied to each cell. The filter is applied after the cell normalizer and may remove cells from the result.
        Parameters:
        cellFilter - The cell filter.
        Returns:
        This builder for chaining method calls.
      • cellNormalizer

        public CsvFormat.Builder cellNormalizer​(UnaryOperator<String> cellNormalizer)
        Sets the cell normalizer that is applied to each cell. The normalizer is applied before the cell filter and may transform the cell into a different cell.
        Parameters:
        cellNormalizer - The cell normalizer.
        Returns:
        This builder for chaining method calls.
      • delimiter

        public CsvFormat.Builder delimiter​(int delimiter)
        Sets the character used to delimit cells.
        Parameters:
        delimiter - The delimiter character.
        Returns:
        This builder for chaining method calls.
      • delimiter

        public CsvFormat.Builder delimiter​(String delimiter)
        Sets the character used to delimit cells.
        Parameters:
        delimiter - The delimiter character.
        Returns:
        This builder for chaining method calls.
      • escape

        public CsvFormat.Builder escape​(int escape)
        Sets the character used to escape special characters in a cell.
        Parameters:
        escape - The escape character.
        Returns:
        This builder for chaining method calls.
      • escape

        public CsvFormat.Builder escape​(String escape)
        Sets the character used to escape special characters in a cell.
        Parameters:
        escape - The escape character.
        Returns:
        This builder for chaining method calls.
      • ignoreBlankCells

        public CsvFormat.Builder ignoreBlankCells​(boolean filterBlankCells)
        Sets up the cellFilter to filter out blank cells.
        Parameters:
        filterBlankCells - If true, blank cells will be filtered out.
        Returns:
        This builder for chaining method calls.
      • ignoreEmptyCells

        public CsvFormat.Builder ignoreEmptyCells​(boolean filterEmptyCells)
        Sets up the cellFilter to filter out empty cells.
        Parameters:
        filterEmptyCells - If true, empty cells will be filtered out.
        Returns:
        This builder for chaining method calls.
      • newlines

        public CsvFormat.Builder newlines​(Collection<String> newlines)
        Sets the characters that are treated as newlines.
        Parameters:
        newlines - The newline characters.
        Returns:
        This builder for chaining method calls.
      • newlines

        public CsvFormat.Builder newlines​(String... newlines)
        Sets the characters that are treated as newlines.
        Parameters:
        newlines - The newline characters.
        Returns:
        This builder for chaining method calls.
      • quote

        public CsvFormat.Builder quote​(String quote)
        Sets the quoteOpen and quoteClose characters to the same value.
        Parameters:
        quote - The quote character.
        Returns:
        This builder for chaining method calls.
      • quote

        public CsvFormat.Builder quote​(int quote)
        Sets the quoteOpen and quoteClose characters to the same value.
        Parameters:
        quote - The quote character.
        Returns:
        This builder for chaining method calls.
      • quoteClose

        public CsvFormat.Builder quoteClose​(int quoteClose)
        Sets the character used to end a quoted cell.
        Parameters:
        quoteClose - The quote character.
        Returns:
        This builder for chaining method calls.
      • quoteClose

        public CsvFormat.Builder quoteClose​(String quoteClose)
        Sets the character used to end a quoted cell.
        Parameters:
        quoteClose - The quote character.
        Returns:
        This builder for chaining method calls.
      • quoteOpen

        public CsvFormat.Builder quoteOpen​(int quoteOpen)
        Sets the character used to start a quoted cell.
        Parameters:
        quoteOpen - The quote character.
        Returns:
        This builder for chaining method calls.
      • quoteOpen

        public CsvFormat.Builder quoteOpen​(String quoteOpen)
        Sets the character used to start a quoted cell.
        Parameters:
        quoteOpen - The quote character.
        Returns:
        This builder for chaining method calls.
      • rowFilter

        public CsvFormat.Builder rowFilter​(Predicate<List<String>> rowFilter)
        Sets the row filter that is applied to each row after it was split into cells. The filter is applied after the cell normalizer and may remove rows from the result.
        Parameters:
        rowFilter - The row filter.
        Returns:
        This builder for chaining method calls.
      • rowMutator

        public CsvFormat.Builder rowMutator​(Consumer<List<String>> rowMutator)
        Sets the row normalizer that is applied to each row after it was split into cells. The normalizer is applied before the row filter and may transform the row into a different row.
        Parameters:
        rowMutator - The row normalizer.
        Returns:
        This builder for chaining method calls.
      • rowNormalizer

        public CsvFormat.Builder rowNormalizer​(UnaryOperator<List<String>> rowNormalizer)
        Sets the row normalizer that is applied to each row after it was split into cells. The normalizer is applied before the row filter and may transform the row into a different row.
        Parameters:
        rowNormalizer - The row normalizer.
        Returns:
        This builder for chaining method calls.
      • treatLineBreaksAsDelimiter

        public CsvFormat.Builder treatLineBreaksAsDelimiter​(boolean treatLineBreaksAsDelimiter)
        When set to true, line breaks will be treated as cell delimiters. Useful when splitting a single row of characters separated values. Not recommended for splitting multiple rows (as it will result in a single row with all cells).
        Parameters:
        treatLineBreaksAsDelimiter - Whether to treat line breaks as delimiters.
        Returns:
        This builder for chaining method calls.
      • trimCells

        public CsvFormat.Builder trimCells​(boolean trimCells)
        Sets up the cellNormalizer to trim cells, i.e. remove leading and trailing whitespace.
        Parameters:
        trimCells - If true, cells will be trimmed.
        Returns:
        This builder for chaining method calls.