Package com.opencsv
Class CSVParserBuilder
- java.lang.Object
-
- com.opencsv.CSVParserBuilder
-
public class CSVParserBuilder extends java.lang.ObjectBuilder for creating a CSVParser.Example code for using this class:
final CSVParser parser =
new CSVParserBuilder()
.withSeparator('\t')
.withIgnoreQuotations(true)
.build();
- See Also:
CSVParser
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.LocaleerrorLocaleprivate charescapeCharprivate booleanignoreLeadingWhiteSpaceprivate booleanignoreQuotationsprivate CSVReaderNullFieldIndicatornullFieldIndicatorprivate charquoteCharprivate charseparatorprivate booleanstrictQuotes
-
Constructor Summary
Constructors Constructor Description CSVParserBuilder()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSVParserbuild()Constructs CSVParser.chargetEscapeChar()chargetQuoteChar()chargetSeparator()booleanisIgnoreLeadingWhiteSpace()booleanisIgnoreQuotations()booleanisStrictQuotes()CSVReaderNullFieldIndicatornullFieldIndicator()CSVParserBuilderwithErrorLocale(java.util.Locale errorLocale)Sets the locale for all error messages.CSVParserBuilderwithEscapeChar(char escapeChar)Sets the character to use for escaping a separator or quote.CSVParserBuilderwithFieldAsNull(CSVReaderNullFieldIndicator fieldIndicator)Sets the NullFieldIndicator.CSVParserBuilderwithIgnoreLeadingWhiteSpace(boolean ignoreLeadingWhiteSpace)Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.CSVParserBuilderwithIgnoreQuotations(boolean ignoreQuotations)Sets the ignore quotations mode - if true, quotations are ignored.CSVParserBuilderwithQuoteChar(char quoteChar)Sets the character to use for quoted elements.CSVParserBuilderwithSeparator(char separator)Sets the delimiter to use for separating entries.CSVParserBuilderwithStrictQuotes(boolean strictQuotes)Sets the strict quotes setting - if true, characters outside the quotes are ignored.
-
-
-
Field Detail
-
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
private CSVReaderNullFieldIndicator nullFieldIndicator
-
errorLocale
private java.util.Locale errorLocale
-
-
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.
-
-