Package com.opencsv
Class CSVParserBuilder
java.lang.Object
com.opencsv.CSVParserBuilder
Builder for creating a CSVParser.
Example code for using this class:
final CSVParser parser =
new CSVParserBuilder()
.withSeparator('\t')
.withIgnoreQuotations(true)
.build();
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Locale
private char
private boolean
private boolean
private CSVReaderNullFieldIndicator
private char
private char
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Constructs CSVParser.char
char
char
boolean
boolean
boolean
withErrorLocale
(Locale errorLocale) Sets the locale for all error messages.withEscapeChar
(char escapeChar) Sets the character to use for escaping a separator or quote.withFieldAsNull
(CSVReaderNullFieldIndicator fieldIndicator) Sets the NullFieldIndicator.withIgnoreLeadingWhiteSpace
(boolean ignoreLeadingWhiteSpace) Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.withIgnoreQuotations
(boolean ignoreQuotations) Sets the ignore quotations mode - if true, quotations are ignored.withQuoteChar
(char quoteChar) Sets the character to use for quoted elements.withSeparator
(char separator) Sets the delimiter to use for separating entries.withStrictQuotes
(boolean strictQuotes) Sets the strict quotes setting - if true, characters outside the quotes are ignored.
-
Field Details
-
separator
private char separator -
quoteChar
private char quoteChar -
escapeChar
private char escapeChar -
strictQuotes
private boolean strictQuotes -
ignoreLeadingWhiteSpace
private boolean ignoreLeadingWhiteSpace -
ignoreQuotations
private boolean ignoreQuotations -
nullFieldIndicator
-
errorLocale
-
-
Constructor Details
-
CSVParserBuilder
public CSVParserBuilder()Default constructor.
-
-
Method Details
-
withSeparator
Sets the delimiter to use for separating entries.- Parameters:
separator
- The delimiter to use for separating entries- Returns:
- The CSVParserBuilder
-
withQuoteChar
Sets the character to use for quoted elements.- Parameters:
quoteChar
- The character to use for quoted element.- Returns:
- The CSVParserBuilder
-
withEscapeChar
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
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
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
Sets the ignore quotations mode - if true, quotations are ignored.- Parameters:
ignoreQuotations
- If true, quotations are ignored- Returns:
- The CSVParserBuilder
-
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
Sets the NullFieldIndicator.- Parameters:
fieldIndicator
- CSVReaderNullFieldIndicator set to what should be considered a null field.- Returns:
- The CSVParserBuilder
-
withErrorLocale
Sets the locale for all error messages.- Parameters:
errorLocale
- Locale for error messages- Returns:
this
- Since:
- 4.0
-
nullFieldIndicator
- Returns:
- The null field indicator.
-