T - The type of the beans being writtenpublic class StatefulBeanToCsvBuilder<T> extends Object
| Constructor and Description |
|---|
StatefulBeanToCsvBuilder(ICSVWriter icsvWriter)
Being stateful the writer is required by the builder at the start and not added in later.
|
StatefulBeanToCsvBuilder(Writer writer)
Default constructor - Being stateful the writer is required by the builder at the start and not added in later.
|
| Modifier and Type | Method and Description |
|---|---|
StatefulBeanToCsv<T> |
build()
Builds a StatefulBeanToCsv from the information provided, filling in
default values where none have been specified.
|
StatefulBeanToCsvBuilder<T> |
withApplyQuotesToAll(boolean applyQuotesToAll)
Sets whether all outputs should be put in quotes.
|
StatefulBeanToCsvBuilder<T> |
withErrorLocale(Locale errorLocale)
Sets the locale to be used for all error messages.
|
StatefulBeanToCsvBuilder<T> |
withEscapechar(char escapechar) |
StatefulBeanToCsvBuilder<T> |
withIgnoreField(Class<?> type,
Field field)
Adds a
Field to the list of fields opencsv should ignore
completely. |
StatefulBeanToCsvBuilder<T> |
withLineEnd(String lineEnd) |
StatefulBeanToCsvBuilder<T> |
withMappingStrategy(MappingStrategy<T> mappingStrategy)
Sets the mapping strategy for writing beans to a CSV destination.
|
StatefulBeanToCsvBuilder<T> |
withOrderedResults(boolean orderedResults)
Sets whether or not results must be written in the same order in which
they appear in the list of beans provided as input.
|
StatefulBeanToCsvBuilder<T> |
withQuotechar(char quotechar) |
StatefulBeanToCsvBuilder<T> |
withSeparator(char separator) |
StatefulBeanToCsvBuilder<T> |
withThrowExceptions(boolean throwExceptions) |
public StatefulBeanToCsvBuilder(Writer writer)
writer - - the writer that will be used to output the csv version of the bean.public StatefulBeanToCsvBuilder(ICSVWriter icsvWriter)
icsvWriter - - the ICSVWriter that will be used to output the csv version of the bean.public StatefulBeanToCsvBuilder<T> withMappingStrategy(MappingStrategy<T> mappingStrategy)
If the mapping strategy is set this way, it will always be used instead of automatic determination of an appropriate mapping strategy.
It is perfectly legitimate to read a CSV source, take the mapping strategy from the read operation, and pass it in to this method for a write operation. This conserves some processing time, but, more importantly, preserves header ordering.
mappingStrategy - The mapping strategy to be used for write operationspublic StatefulBeanToCsvBuilder<T> withSeparator(char separator)
separator - The field separator to be used when writing a CSV fileCSVWriter.separatorpublic StatefulBeanToCsvBuilder<T> withQuotechar(char quotechar)
quotechar - The quote character to be used when writing a CSV fileCSVWriter.quotecharpublic StatefulBeanToCsvBuilder<T> withEscapechar(char escapechar)
escapechar - The escape character to be used when writing a CSV fileCSVWriter.escapecharpublic StatefulBeanToCsvBuilder<T> withLineEnd(String lineEnd)
lineEnd - The line ending to be used when writing a CSV fileAbstractCSVWriter.lineEndpublic StatefulBeanToCsvBuilder<T> withThrowExceptions(boolean throwExceptions)
throwExceptions - Whether or not exceptions should be thrown while
writing a CSV file. If not, they may be retrieved later by calling
StatefulBeanToCsv.getCapturedExceptions().public StatefulBeanToCsvBuilder<T> withOrderedResults(boolean orderedResults)
orderedResults - Whether or not the lines written are in the same
order they appeared in the inputStatefulBeanToCsv.setOrderedResults(boolean)public StatefulBeanToCsvBuilder<T> withErrorLocale(Locale errorLocale)
errorLocale - Locale for error messages. If null, the default locale
is used.StatefulBeanToCsv.setErrorLocale(java.util.Locale)public StatefulBeanToCsvBuilder<T> withApplyQuotesToAll(boolean applyQuotesToAll)
true.applyQuotesToAll - Whether all outputs should be quotedAbstractCSVWriter.writeNext(String[], boolean)public StatefulBeanToCsvBuilder<T> withIgnoreField(Class<?> type, Field field) throws IllegalArgumentException
Field to the list of fields opencsv should ignore
completely.
May be called as many times as necessary.
type - The class opencsv will encounter the field in during
processing. In the case of inheritance, this may not be the
declaring class.field - The field opencsv is to ignorethisIllegalArgumentException - If one of the parameters is
null or field cannot be found in type.MappingStrategy.ignoreFields(MultiValuedMap)public StatefulBeanToCsv<T> build()
StatefulBeanToCsvCopyright © 2019. All rights reserved.