Package com.opencsv
Class CSVReaderHeaderAwareBuilder
- java.lang.Object
-
- com.opencsv.CSVReaderBaseBuilder<CSVReaderHeaderAware>
-
- com.opencsv.CSVReaderHeaderAwareBuilder
-
public class CSVReaderHeaderAwareBuilder extends CSVReaderBaseBuilder<CSVReaderHeaderAware>
Builder forCSVReaderHeaderAware.- Since:
- 4.2
-
-
Field Summary
-
Fields inherited from class com.opencsv.CSVReaderBaseBuilder
errorLocale, icsvParser, keepCR, lineValidatorAggregator, multilineLimit, nullFieldIndicator, reader, rowProcessor, rowValidatorAggregator, skipLines, verifyReader
-
-
Constructor Summary
Constructors Constructor Description CSVReaderHeaderAwareBuilder(java.io.Reader reader)Sets the reader to an underlying CSV source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSVReaderHeaderAwarebuild()Creates theCSVReaderHeaderAware.CSVReaderHeaderAwareBuilderwithCSVParser(ICSVParser icsvParser)Sets the parser to use to parse the input.CSVReaderHeaderAwareBuilderwithErrorLocale(java.util.Locale errorLocale)Sets the locale for all error messages.CSVReaderHeaderAwareBuilderwithFieldAsNull(CSVReaderNullFieldIndicator indicator)Checks to see if it should treat a field with two separators, two quotes, or both as a null field.CSVReaderHeaderAwareBuilderwithKeepCarriageReturn(boolean keepCR)Sets if the reader will keep or discard carriage returns.CSVReaderHeaderAwareBuilderwithLineValidator(LineValidator lineValidator)Adds aLineValidatorto theCSVReaderHeaderAware.CSVReaderHeaderAwareBuilderwithMultilineLimit(int multilineLimit)Sets the maximum number of lines allowed in a multiline record.CSVReaderHeaderAwareBuilderwithRowProcessor(RowProcessor rowProcessor)Adds aRowProcessorto theCSVReaderHeaderAware.CSVReaderHeaderAwareBuilderwithRowValidator(RowValidator rowValidator)Adds aRowValidatorto theCSVReaderHeaderAware.CSVReaderHeaderAwareBuilderwithSkipLines(int skipLines)Sets the number of lines to skip before reading.CSVReaderHeaderAwareBuilderwithVerifyReader(boolean verifyReader)Checks to see if theCSVReaderHeaderAwareshould verify the reader state before reads or not.-
Methods inherited from class com.opencsv.CSVReaderBaseBuilder
getCsvParser, getErrorLocale, getLineValidatorAggregator, getMultilineLimit, getOrCreateCsvParser, getReader, getRowValidatorAggregator, getSkipLines, isVerifyReader, keepCarriageReturn
-
-
-
-
Method Detail
-
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 theCSVReaderHeaderAwareshould 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 ifCSVReaderHeaderAwareshould 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-CSVReaderNullFieldIndicatorset 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 isCSVReader.DEFAULT_MULTILINE_LIMIT.- Returns:
this
-
withErrorLocale
public CSVReaderHeaderAwareBuilder withErrorLocale(java.util.Locale errorLocale)
Sets the locale for all error messages.- Parameters:
errorLocale- Locale for error messages- Returns:
this- Since:
- 4.0
-
withLineValidator
public CSVReaderHeaderAwareBuilder withLineValidator(LineValidator lineValidator)
Adds aLineValidatorto theCSVReaderHeaderAware. MultipleLineValidators can be added with multiple calls.- Parameters:
lineValidator-LineValidatorto inject.- Returns:
this- Since:
- 5.0
-
withRowValidator
public CSVReaderHeaderAwareBuilder withRowValidator(RowValidator rowValidator)
Adds aRowValidatorto theCSVReaderHeaderAware. MultipleRowValidators can be added with multiple calls.- Parameters:
rowValidator-RowValidatorto inject- Returns:
this- Since:
- 5.0
-
withRowProcessor
public CSVReaderHeaderAwareBuilder withRowProcessor(RowProcessor rowProcessor)
Adds aRowProcessorto theCSVReaderHeaderAware. Only a singleRowProcessorcan be added so multiple calls will overwrite the previously setRowProcessor.- Parameters:
rowProcessor-RowProcessorto inject- Returns:
this- Since:
- 5.0
-
build
public CSVReaderHeaderAware build() throws java.lang.RuntimeException
Creates theCSVReaderHeaderAware.- Specified by:
buildin classCSVReaderBaseBuilder<CSVReaderHeaderAware>- Returns:
- The
CSVReaderHeaderAwarebased on the set criteria. - Throws:
java.lang.RuntimeException- If the header mapping cannot be initialized from the first line of data
-
-