java.io.Writer ,
keeping state information and making an intelligent guess at the mapping
strategy to be applied.
This class implements multi-threading on writing more than one bean, so there should be no need to use it across threads in an application. As such, it is not thread-safe.
OpencsvUtils#determineMappingStrategy(java.lang.Class, java.util.Locale, java.lang.String)
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private List | |
| private ICSVWriter | |
| private Locale | |
| private final char | |
| private final CsvExceptionHandler | |
| private BeanExecutor | |
| private boolean | |
| private final MultiValuedMap | |
| private final String | |
| private int | lineNumber
The beans being written are counted in the order they are written. |
| private MappingStrategy | |
| private static final char | |
| private boolean | |
| private final String | |
| private final char | |
| private final char | |
| private final Writer |
| Access | Constructor and Description |
|---|---|
| pack-priv | StatefulBeanToCsv(char
The escape character to use when writing a CSV file escapechar, String The line ending to use when writing a CSV file lineEnd, MappingStrategy<T> The mapping strategy to use when writing a CSV file mappingStrategy, char The quote character to use when writing a CSV file quotechar, char The field separator to use when writing a CSV file separator, CsvExceptionHandler Determines the exception handling behavior exceptionHandler, Writer A writer, boolean java. for writing the beans as a CSV toWhether all output fields should be quoted applyQuotesToAll, MultiValuedMap<Class<?>, Field> The fields to ignore during processing. May be ignoredFields, String null.The profile to use when configuring how to interpret bean fields profile)Constructor used when supplying a Writer instead of a CsvWriter class. |
| public | StatefulBeanToCsv(MappingStrategy<T>
The mapping strategy to use when writing a CSV file mappingStrategy, CsvExceptionHandler Determines the exception handling behavior exceptionHandler, boolean Whether all output fields should be quoted applyQuotesToAll, ICSVWriter An user-supplied csvWriter, MultiValuedMap<Class<?>, Field> com. for writing beans to a CSV outputThe fields to ignore during processing. May be ignoredFields, String null.The profile to use when configuring how to interpret bean fields profile)Constructor used to allow building of a |
| Modifier and Type | Method and Description |
|---|---|
| private void | beforeFirstWrite(T
Any bean to be written. Used to determine the mapping
strategy automatically. The bean itself is not written to the output by
this method. bean)Custodial tasks that must be performed before beans are written to a CSV destination for the first time. |
| public List | Returns: A list of exceptions that would have been thrown during any and all read operations since the last call to this methodAny exceptions captured during writing of beans to a CSV destination can be retrieved through this method. |
| public boolean | isThrowExceptions()
Deprecated
There is simply no need for this method.
Returns: Whether or not exceptions are thrown. |
| public void | setErrorLocale(Locale
Locale for error messages. If null, the default locale
is used. errorLocale)Sets the locale for all error messages. |
| public void | setOrderedResults(boolean
Whether or not the lines written are in the same
order they appeared in the input 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. |
| private void | |
| public void | write(T
A bean to be written to a CSV destination bean)Writes a bean out to the |
| public void | write(List<T>
A list of beans to be written to a CSV destination beans)Writes a list of beans out to the |
| public void | write(Iterator<T>
An iterator of beans to be written to a CSV destination iBeans)Writes an iterator of beans out to the |
| public void | write(Stream<T>
A stream of beans to be written to a CSV destination beans)Writes a stream of beans out to the |
| applyQuotesToAll | back to summary |
|---|---|
| private final boolean applyQuotesToAll | |
| capturedExceptions | back to summary |
|---|---|
| private List<CsvException> capturedExceptions | |
| csvwriter | back to summary |
|---|---|
| private ICSVWriter csvwriter | |
| errorLocale | back to summary |
|---|---|
| private Locale errorLocale | |
| escapechar | back to summary |
|---|---|
| private final char escapechar | |
| exceptionHandler | back to summary |
|---|---|
| private final CsvExceptionHandler exceptionHandler | |
| executor | back to summary |
|---|---|
| private BeanExecutor<T> executor | |
| headerWritten | back to summary |
|---|---|
| private boolean headerWritten | |
| ignoredFields | back to summary |
|---|---|
| private final MultiValuedMap<Class<?>, Field> ignoredFields | |
| lineEnd | back to summary |
|---|---|
| private final String lineEnd | |
| lineNumber | back to summary |
|---|---|
| private int lineNumber The beans being written are counted in the order they are written. | |
| mappingStrategy | back to summary |
|---|---|
| private MappingStrategy<T> mappingStrategy | |
| NO_CHARACTER | back to summary |
|---|---|
| private static final char NO_CHARACTER | |
| orderedResults | back to summary |
|---|---|
| private boolean orderedResults | |
| profile | back to summary |
|---|---|
| private final String profile | |
| quotechar | back to summary |
|---|---|
| private final char quotechar | |
| separator | back to summary |
|---|---|
| private final char separator | |
| writer | back to summary |
|---|---|
| private final Writer writer | |
| StatefulBeanToCsv | back to summary |
|---|---|
| pack-priv StatefulBeanToCsv(char escapechar, String lineEnd, MappingStrategy<T> mappingStrategy, char quotechar, char separator, CsvExceptionHandler exceptionHandler, Writer writer, boolean applyQuotesToAll, MultiValuedMap<Class<?>, Field> ignoredFields, String profile) Constructor used when supplying a Writer instead of a CsvWriter class.
It is defined as package protected to ensure that
| |
| StatefulBeanToCsv | back to summary |
|---|---|
| public StatefulBeanToCsv(MappingStrategy<T> mappingStrategy, CsvExceptionHandler exceptionHandler, boolean applyQuotesToAll, ICSVWriter csvWriter, MultiValuedMap<Class<?>, Field> ignoredFields, String profile) Constructor used to allow building of a
| |
| beforeFirstWrite | back to summary |
|---|---|
| private void beforeFirstWrite(T bean) throws CsvRequiredFieldEmptyException Custodial tasks that must be performed before beans are written to a CSV destination for the first time.
| |
| getCapturedExceptions | back to summary |
|---|---|
| public List Any exceptions captured during writing of beans to a CSV destination can be retrieved through this method. Reads from the list are destructive! Calling this method will
clear the list of captured exceptions. However, calling
| |
| isThrowExceptions | back to summary |
|---|---|
| public boolean isThrowExceptions()
Deprecated There is simply no need for this method.
| |
| setErrorLocale | back to summary |
|---|---|
| public void setErrorLocale(Locale errorLocale) Sets the locale for all error messages.
| |
| setOrderedResults | back to summary |
|---|---|
| public void setOrderedResults(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.
The default is that order is preserved. If your data do not need to be
ordered, you can get a slight performance boost by setting
| |
| submitAllLines | back to summary |
|---|---|
| private void submitAllLines(Iterator<T> beans) throws InterruptedException | |
| write | back to summary |
|---|---|
| public void write(T bean) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException Writes a bean out to the
| |
| write | back to summary |
|---|---|
| public void write(List<T> beans) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException Writes a list of beans out to the
| |
| write | back to summary |
|---|---|
| public void write(Iterator<T> iBeans) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException Writes an iterator of beans out to the
| |
| write | back to summary |
|---|---|
| public void write(Stream<T> beans) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException Writes a stream of beans out to the
| |