Package com.opencsv
Class CSVParserBuilder
- java.lang.Object
-
- com.opencsv.CSVParserBuilder
-
public class CSVParserBuilder extends java.lang.Object
Builder for creating a CSVParser.Example code for using this class:
final CSVParser parser =
new CSVParserBuilder()
.withSeparator('\t')
.withIgnoreQuotations(true)
.build();
- See Also:
CSVParser
-
-
Constructor Summary
Constructors Constructor Description CSVParserBuilder()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSVParser
build()
Constructs CSVParser.char
getEscapeChar()
char
getQuoteChar()
char
getSeparator()
boolean
isIgnoreLeadingWhiteSpace()
boolean
isIgnoreQuotations()
boolean
isStrictQuotes()
CSVReaderNullFieldIndicator
nullFieldIndicator()
CSVParserBuilder
withErrorLocale(java.util.Locale errorLocale)
Sets the locale for all error messages.CSVParserBuilder
withEscapeChar(char escapeChar)
Sets the character to use for escaping a separator or quote.CSVParserBuilder
withFieldAsNull(CSVReaderNullFieldIndicator fieldIndicator)
Sets the NullFieldIndicator.CSVParserBuilder
withIgnoreLeadingWhiteSpace(boolean ignoreLeadingWhiteSpace)
Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.CSVParserBuilder
withIgnoreQuotations(boolean ignoreQuotations)
Sets the ignore quotations mode - if true, quotations are ignored.CSVParserBuilder
withQuoteChar(char quoteChar)
Sets the character to use for quoted elements.CSVParserBuilder
withSeparator(char separator)
Sets the delimiter to use for separating entries.CSVParserBuilder
withStrictQuotes(boolean strictQuotes)
Sets the strict quotes setting - if true, characters outside the quotes are ignored.
-
-
-
Method Detail
-
withSeparator
public CSVParserBuilder withSeparator(char separator)
Sets the delimiter to use for separating entries.- Parameters:
separator
- The delimiter to use for separating entries- Returns:
- The CSVParserBuilder
-
withQuoteChar
public CSVParserBuilder withQuoteChar(char quoteChar)
Sets the character to use for quoted elements.- Parameters:
quoteChar
- The character to use for quoted element.- Returns:
- The CSVParserBuilder
-
withEscapeChar
public CSVParserBuilder withEscapeChar(char escapeChar)
Sets the character to use for escaping a separator or quote.- Parameters:
escapeChar
- The character to use for escaping a separator or quote.- Returns:
- The CSVParserBuilder
-
withStrictQuotes
public CSVParserBuilder withStrictQuotes(boolean strictQuotes)
Sets the strict quotes setting - if true, characters outside the quotes are ignored.- Parameters:
strictQuotes
- If true, characters outside the quotes are ignored- Returns:
- The CSVParserBuilder
-
withIgnoreLeadingWhiteSpace
public CSVParserBuilder withIgnoreLeadingWhiteSpace(boolean ignoreLeadingWhiteSpace)
Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.- Parameters:
ignoreLeadingWhiteSpace
- If true, white space in front of a quote in a field is ignored- Returns:
- The CSVParserBuilder
-
withIgnoreQuotations
public CSVParserBuilder withIgnoreQuotations(boolean ignoreQuotations)
Sets the ignore quotations mode - if true, quotations are ignored.- Parameters:
ignoreQuotations
- If true, quotations are ignored- Returns:
- The CSVParserBuilder
-
build
public CSVParser build()
Constructs CSVParser.- Returns:
- A new CSVParser with defined settings.
-
getSeparator
public char getSeparator()
- Returns:
- The defined separator.
-
getQuoteChar
public char getQuoteChar()
- Returns:
- The defined quotation character.
-
getEscapeChar
public char getEscapeChar()
- Returns:
- The defined escape character.
-
isStrictQuotes
public boolean isStrictQuotes()
- Returns:
- The defined strict quotation setting.
-
isIgnoreLeadingWhiteSpace
public boolean isIgnoreLeadingWhiteSpace()
- Returns:
- The defined ignoreLeadingWhiteSpace setting.
-
isIgnoreQuotations
public boolean isIgnoreQuotations()
- Returns:
- The defined ignoreQuotation setting.
-
withFieldAsNull
public CSVParserBuilder withFieldAsNull(CSVReaderNullFieldIndicator fieldIndicator)
Sets the NullFieldIndicator.- Parameters:
fieldIndicator
- CSVReaderNullFieldIndicator set to what should be considered a null field.- Returns:
- The CSVParserBuilder
-
withErrorLocale
public CSVParserBuilder withErrorLocale(java.util.Locale errorLocale)
Sets the locale for all error messages.- Parameters:
errorLocale
- Locale for error messages- Returns:
this
- Since:
- 4.0
-
nullFieldIndicator
public CSVReaderNullFieldIndicator nullFieldIndicator()
- Returns:
- The null field indicator.
-
-