Class CSVReaderHeaderAwareBuilder


public class CSVReaderHeaderAwareBuilder extends CSVReaderBaseBuilder<CSVReaderHeaderAware>
Since:
4.2
Author:
Andre Rosot
  • Constructor Details

    • CSVReaderHeaderAwareBuilder

      public CSVReaderHeaderAwareBuilder(Reader reader)
      Sets the reader to an underlying CSV source.
      Parameters:
      reader - The reader to an underlying CSV source.
  • Method Details

    • withSkipLines

      public CSVReaderHeaderAwareBuilder withSkipLines(int skipLines)
      Sets the number of lines to skip before reading.
      Parameters:
      skipLines - The number of lines to skip before reading.
      Returns:
      this
    • withCSVParser

      public CSVReaderHeaderAwareBuilder withCSVParser(ICSVParser icsvParser)
      Sets the parser to use to parse the input.
      Parameters:
      icsvParser - The parser to use to parse the input.
      Returns:
      this
    • withKeepCarriageReturn

      public CSVReaderHeaderAwareBuilder withKeepCarriageReturn(boolean keepCR)
      Sets if the reader will keep or discard carriage returns.
      Parameters:
      keepCR - True to keep carriage returns, false to discard.
      Returns:
      this
    • withVerifyReader

      public CSVReaderHeaderAwareBuilder withVerifyReader(boolean verifyReader)
      Checks to see if the CSVReaderHeaderAware should verify the reader state before reads or not.

      This should be set to false if you are using some form of asynchronous reader (like readers created by the java.nio.* classes).

      The default value is true.

      Parameters:
      verifyReader - True if CSVReaderHeaderAware should verify reader before each read, false otherwise.
      Returns:
      this
    • withFieldAsNull

      public CSVReaderHeaderAwareBuilder withFieldAsNull(CSVReaderNullFieldIndicator indicator)
      Checks to see if it should treat a field with two separators, two quotes, or both as a null field.
      Parameters:
      indicator - CSVReaderNullFieldIndicator set to what should be considered a null field.
      Returns:
      this
    • withMultilineLimit

      public CSVReaderHeaderAwareBuilder withMultilineLimit(int multilineLimit)
      Sets the maximum number of lines allowed in a multiline record. More than this number in one record results in an IOException.
      Parameters:
      multilineLimit - No more than this number of lines is allowed in a single input record. The default is CSVReader.DEFAULT_MULTILINE_LIMIT.
      Returns:
      this
    • withErrorLocale

      public CSVReaderHeaderAwareBuilder withErrorLocale(Locale errorLocale)
      Sets the locale for all error messages.
      Parameters:
      errorLocale - Locale for error messages
      Returns:
      this
      Since:
      4.0
    • withLineValidator

      public CSVReaderHeaderAwareBuilder withLineValidator(com.opencsv.validators.LineValidator lineValidator)
      Adds a LineValidator to the CSVReaderHeaderAware. Multiple LineValidators can be added with multiple calls.
      Parameters:
      lineValidator - LineValidator to inject.
      Returns:
      this
      Since:
      5.0
    • withRowValidator

      public CSVReaderHeaderAwareBuilder withRowValidator(com.opencsv.validators.RowValidator rowValidator)
      Adds a RowValidator to the CSVReaderHeaderAware. Multiple RowValidators can be added with multiple calls.
      Parameters:
      rowValidator - RowValidator to inject
      Returns:
      this
      Since:
      5.0
    • withRowProcessor

      public CSVReaderHeaderAwareBuilder withRowProcessor(com.opencsv.processor.RowProcessor rowProcessor)
      Adds a RowProcessor to the CSVReaderHeaderAware. Only a single RowProcessor can be added so multiple calls will overwrite the previously set RowProcessor.
      Parameters:
      rowProcessor - RowProcessor to inject
      Returns:
      this
      Since:
      5.0
    • build

      public CSVReaderHeaderAware build() throws RuntimeException
      Specified by:
      build in class CSVReaderBaseBuilder<CSVReaderHeaderAware>
      Returns:
      The CSVReaderHeaderAware based on the set criteria.
      Throws:
      RuntimeException - If the header mapping cannot be initialized from the first line of data