Top Description Fields Constructors Methods
com.opencsv

public Class CSVParserBuilder

extends Object
Class Inheritance
Imports
com.opencsv.enums.CSVReaderNullFieldIndicator, org.apache.commons.lang3.ObjectUtils, java.util.Locale

Builder 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

Modifier and TypeField and Description
private Locale
private char
private boolean
private boolean
private CSVReaderNullFieldIndicator
private char
private char
private boolean

Constructor Summary

AccessConstructor and Description
public
CSVParserBuilder()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public CSVParser

Returns:

A new CSVParser with defined settings.
build
()

Constructs CSVParser.

public char
getEscapeChar()

Returns: The defined escape character.

public CSVReaderNullFieldIndicator
getNullFieldIndicator()

Returns: The null field indicator.

public char
getQuoteChar()

Returns: The defined quotation character.

public char
getSeparator()

Returns: The defined separator.

public boolean
isIgnoreLeadingWhiteSpace()

Returns: The defined ignoreLeadingWhiteSpace setting.

public boolean
isIgnoreQuotations()

Returns: The defined ignoreQuotation setting.

public boolean
isStrictQuotes()

Returns: The defined strict quotation setting.

public CSVReaderNullFieldIndicator
nullFieldIndicator()
Deprecated As of 5.11.3, replaced by getNullFieldIndicator().

Returns: The null field indicator.

public CSVParserBuilder

Returns:

this
withErrorLocale
(Locale
Locale for error messages
errorLocale
)

Sets the locale for all error messages.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withEscapeChar
(final char
The character to use for escaping a separator or quote.
escapeChar
)

Sets the character to use for escaping a separator or quote.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withFieldAsNull
(final CSVReaderNullFieldIndicator
CSVReaderNullFieldIndicator set to what should be considered a null field.
fieldIndicator
)

Sets the NullFieldIndicator.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withIgnoreLeadingWhiteSpace
(final boolean
If true, white space in front of a quote in a field is ignored
ignoreLeadingWhiteSpace
)

Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withIgnoreQuotations
(final boolean
If true, quotations are ignored
ignoreQuotations
)

Sets the ignore quotations mode - if true, quotations are ignored.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withQuoteChar
(final char
The character to use for quoted element.
quoteChar
)

Sets the character to use for quoted elements.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withSeparator
(final char
The delimiter to use for separating entries
separator
)

Sets the delimiter to use for separating entries.

public CSVParserBuilder

Returns:

The CSVParserBuilder
withStrictQuotes
(final boolean
If true, characters outside the quotes are ignored
strictQuotes
)

Sets the strict quotes setting - if true, characters outside the quotes are ignored.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorLocaleback to summary
private Locale errorLocale
escapeCharback to summary
private char escapeChar
ignoreLeadingWhiteSpaceback to summary
private boolean ignoreLeadingWhiteSpace
ignoreQuotationsback to summary
private boolean ignoreQuotations
nullFieldIndicatorback to summary
private CSVReaderNullFieldIndicator nullFieldIndicator
quoteCharback to summary
private char quoteChar
separatorback to summary
private char separator
strictQuotesback to summary
private boolean strictQuotes

Constructor Detail

CSVParserBuilderback to summary
public CSVParserBuilder()

Default constructor.

Method Detail

buildback to summary
public CSVParser build()

Constructs CSVParser.

Returns:CSVParser

A new CSVParser with defined settings.

getEscapeCharback to summary
public char getEscapeChar()
Returns:char

The defined escape character.

getNullFieldIndicatorback to summary
public CSVReaderNullFieldIndicator getNullFieldIndicator()
Returns:CSVReaderNullFieldIndicator

The null field indicator.

Since
5.11.3
getQuoteCharback to summary
public char getQuoteChar()
Returns:char

The defined quotation character.

getSeparatorback to summary
public char getSeparator()
Returns:char

The defined separator.

isIgnoreLeadingWhiteSpaceback to summary
public boolean isIgnoreLeadingWhiteSpace()
Returns:boolean

The defined ignoreLeadingWhiteSpace setting.

isIgnoreQuotationsback to summary
public boolean isIgnoreQuotations()
Returns:boolean

The defined ignoreQuotation setting.

isStrictQuotesback to summary
public boolean isStrictQuotes()
Returns:boolean

The defined strict quotation setting.

nullFieldIndicatorback to summary
public CSVReaderNullFieldIndicator nullFieldIndicator()

Deprecated

As of 5.11.3, replaced by getNullFieldIndicator().

Returns:CSVReaderNullFieldIndicator

The null field indicator.

Annotations
@Deprecated
withErrorLocaleback to summary
public CSVParserBuilder withErrorLocale(Locale errorLocale)

Sets the locale for all error messages.

Parameters
errorLocale:Locale

Locale for error messages

Returns:CSVParserBuilder

this

Since
4.0
withEscapeCharback to summary
public CSVParserBuilder withEscapeChar(final char escapeChar)

Sets the character to use for escaping a separator or quote.

Parameters
escapeChar:char

The character to use for escaping a separator or quote.

Returns:CSVParserBuilder

The CSVParserBuilder

withFieldAsNullback to summary
public CSVParserBuilder withFieldAsNull(final CSVReaderNullFieldIndicator fieldIndicator)

Sets the NullFieldIndicator.

Parameters
fieldIndicator:CSVReaderNullFieldIndicator

CSVReaderNullFieldIndicator set to what should be considered a null field.

Returns:CSVParserBuilder

The CSVParserBuilder

withIgnoreLeadingWhiteSpaceback to summary
public CSVParserBuilder withIgnoreLeadingWhiteSpace(final boolean ignoreLeadingWhiteSpace)

Sets the ignore leading whitespace setting - if true, white space in front of a quote in a field is ignored.

Parameters
ignoreLeadingWhiteSpace:boolean

If true, white space in front of a quote in a field is ignored

Returns:CSVParserBuilder

The CSVParserBuilder

withIgnoreQuotationsback to summary
public CSVParserBuilder withIgnoreQuotations(final boolean ignoreQuotations)

Sets the ignore quotations mode - if true, quotations are ignored.

Parameters
ignoreQuotations:boolean

If true, quotations are ignored

Returns:CSVParserBuilder

The CSVParserBuilder

withQuoteCharback to summary
public CSVParserBuilder withQuoteChar(final char quoteChar)

Sets the character to use for quoted elements.

Parameters
quoteChar:char

The character to use for quoted element.

Returns:CSVParserBuilder

The CSVParserBuilder

withSeparatorback to summary
public CSVParserBuilder withSeparator(final char separator)

Sets the delimiter to use for separating entries.

Parameters
separator:char

The delimiter to use for separating entries

Returns:CSVParserBuilder

The CSVParserBuilder

withStrictQuotesback to summary
public CSVParserBuilder withStrictQuotes(final boolean strictQuotes)

Sets the strict quotes setting - if true, characters outside the quotes are ignored.

Parameters
strictQuotes:boolean

If true, characters outside the quotes are ignored

Returns:CSVParserBuilder

The CSVParserBuilder