parse() method with the Iterator is
not supported and will lead to unpredictable results. Additionally, reusing
an instance of this class after all beans have been read is not supported
and will certainly break something.
| Modifier and Type | Class and Description |
|---|---|
| private class | CsvToBean.
A private inner class for implementing an iterator for the input data. |
| Modifier and Type | Field and Description |
|---|---|
| private final List | capturedExceptions
A list of all exceptions during parsing and mapping of the input. |
| private CSVReader | csvReader
The reader this class will use to access the data to be read. |
| private Locale | errorLocale
The errorLocale for error messages. |
| private CsvExceptionHandler | exceptionHandler
Determines how exceptions thrown during processing will be handled. |
| private LineExecutor | executor
The |
| private CsvToBeanFilter | filter
The filter this class will use on the beans it reads. |
| private boolean | ignoreEmptyLines
When an empty line is encountered (not part of the data) then it is ignored. |
| private MappingStrategy | mappingStrategy
The mapping strategy to be used by this CsvToBean. |
| private boolean | orderedResults
Determines whether resulting data sets have to be in the same order as the input. |
| private List | verifiers
All verifiers that should be run on beans after creation but before returning them to the caller. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | Returns: The list of exceptions captured while processing the input fileReturns the list of all exceptions that would have been thrown during the import, but were queued by the exception handler. |
| pack-priv CsvExceptionHandler | Returns: CsvExceptionHandler used by the CsvToBean object.Package scope method currently used by the CsvToBeanBuilderTest |
| public Iterator | Returns: An iterator over the beans created from the inputImplements java. The iterator returned by this method takes one line of input at a time and returns one bean at a time. |
| public List | Returns: A list of populated beans based on the inputParses the input based on parameters already set through other methods. |
| private void | |
| public void | setCsvReader(CSVReader
Reader for input csvReader)Sets the reader to be used to read in the information from the CSV input. |
| public void | setErrorLocale(Locale
Locale for error messages. If null, the default locale
is used. errorLocale)Sets the locale for error messages. |
| public void | setExceptionHandler(CsvExceptionHandler
The exception handler to be used. If handler)null,
this method does nothing.Sets the handler for recoverable exceptions raised during processing of records. |
| public void | setFilter(CsvToBeanFilter
A class that filters the input lines filter)Sets a filter to selectively remove some lines of input before they become beans. |
| public void | setIgnoreEmptyLines(boolean
true to ignore empty lines, false otherwiseIgnores any blank lines in the data that are not part of a field. |
| public void | setMappingStrategy(MappingStrategy<? extends T>
Mapping strategy to convert CSV input to a bean mappingStrategy)Sets the mapping strategy to be used by this bean. |
| public void | setOrderedResults(boolean
Whether or not the beans returned are in the same
order they appeared in the input orderedResults)Sets whether or not results must be returned in the same order in which they appear in the input. |
| public void | setThrowExceptions(boolean
Whether or not to throw exceptions during
processing throwExceptions)Determines whether errors during import should be thrown or kept in a
list for later retrieval via |
| public void | setVerifiers(List<BeanVerifier<T>>
A list of verifiers. May be verifiers)null, in which
case, no verifiers are run.Sets the list of verifiers to be run on all beans after creation. |
| public Stream | Returns: A stream of populated beans based on the inputParses the input based on parameters already set through other methods. |
| capturedExceptions | back to summary |
|---|---|
| private final List<CsvException> capturedExceptions A list of all exceptions during parsing and mapping of the input. | |
| csvReader | back to summary |
|---|---|
| private CSVReader csvReader The reader this class will use to access the data to be read. | |
| errorLocale | back to summary |
|---|---|
| private Locale errorLocale The errorLocale for error messages. | |
| exceptionHandler | back to summary |
|---|---|
| private CsvExceptionHandler exceptionHandler Determines how exceptions thrown during processing will be handled. | |
| executor | back to summary |
|---|---|
| private LineExecutor<T> executor The | |
| filter | back to summary |
|---|---|
| private CsvToBeanFilter filter The filter this class will use on the beans it reads. | |
| ignoreEmptyLines | back to summary |
|---|---|
| private boolean ignoreEmptyLines When an empty line is encountered (not part of the data) then it is
ignored.
By default this is | |
| mappingStrategy | back to summary |
|---|---|
| private MappingStrategy<? extends T> mappingStrategy The mapping strategy to be used by this CsvToBean. | |
| orderedResults | back to summary |
|---|---|
| private boolean orderedResults Determines whether resulting data sets have to be in the same order as the input. | |
| verifiers | back to summary |
|---|---|
| private List<BeanVerifier<T>> verifiers All verifiers that should be run on beans after creation but before returning them to the caller. | |
| CsvToBean | back to summary |
|---|---|
| public CsvToBean() Default constructor. | |
| getCapturedExceptions | back to summary |
|---|---|
| public List Returns the list of all exceptions that would have been thrown during the import, but were queued by the exception handler. The results returned by this method are not consistent until parsing is concluded.
| |
| getExceptionHandler | back to summary |
|---|---|
| pack-priv CsvExceptionHandler getExceptionHandler() Package scope method currently used by the CsvToBeanBuilderTest
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. The iterator returned by this method takes one line of input at a time and returns one bean at a time. The advantage to this method is saving memory. The cost is the loss of parallel processing, reducing throughput. The iterator respects all aspects of | |
| parse | back to summary |
|---|---|
| public List Parses the input based on parameters already set through other methods.
| |
| prepareToReadInput | back to summary |
|---|---|
| private void prepareToReadInput() throws IllegalStateException | |
| setCsvReader | back to summary |
|---|---|
| public void setCsvReader(CSVReader csvReader) Sets the reader to be used to read in the information from the CSV input.
| |
| setErrorLocale | back to summary |
|---|---|
| public void setErrorLocale(Locale errorLocale) Sets the locale for error messages.
| |
| setExceptionHandler | back to summary |
|---|---|
| public void setExceptionHandler(CsvExceptionHandler handler) Sets the handler for recoverable exceptions raised during processing of records. If neither this method nor Please note that if both this method and
| |
| setFilter | back to summary |
|---|---|
| public void setFilter(CsvToBeanFilter filter) Sets a filter to selectively remove some lines of input before they become beans.
| |
| setIgnoreEmptyLines | back to summary |
|---|---|
| public void setIgnoreEmptyLines(boolean ignoreEmptyLines) Ignores any blank lines in the data that are not part of a field.
| |
| setMappingStrategy | back to summary |
|---|---|
| public void setMappingStrategy(MappingStrategy<? extends T> mappingStrategy) Sets the mapping strategy to be used by this bean.
| |
| setOrderedResults | back to summary |
|---|---|
| public void setOrderedResults(boolean orderedResults) Sets whether or not results must be returned in the same order in which
they appear in the 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
| |
| setThrowExceptions | back to summary |
|---|---|
| public void setThrowExceptions(boolean throwExceptions) Determines whether errors during import should be thrown or kept in a
list for later retrieval via This is a convenience function and is maintained for backwards
compatibility. Passing in Please note that if both this method and
| |
| setVerifiers | back to summary |
|---|---|
| public void setVerifiers(List<BeanVerifier<T>> verifiers) Sets the list of verifiers to be run on all beans after creation.
| |
| stream | back to summary |
|---|---|
| public Stream Parses the input based on parameters already set through other methods.
This method saves a marginal amount of time and storage compared to
| |
| Modifier and Type | Field and Description |
|---|---|
| private T | |
| private String[] | |
| private long | |
| private final SingleLineReader | |
| private final BlockingQueue | |
| private final BlockingQueue |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public T | |
| private void | |
| private void | |
| private void | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| bean | back to summary |
|---|---|
| private T bean | |
| line | back to summary |
|---|---|
| private String[] line | |
| lineProcessed | back to summary |
|---|---|
| private long lineProcessed | |
| lineReader | back to summary |
|---|---|
| private final SingleLineReader lineReader | |
| resultantBeansQueue | back to summary |
|---|---|
| private final BlockingQueue<OrderedObject<T>> resultantBeansQueue | |
| thrownExceptionsQueue | back to summary |
|---|---|
| private final BlockingQueue<OrderedObject<CsvException>> thrownExceptionsQueue | |
| CsvToBeanIterator | back to summary |
|---|---|
| pack-priv CsvToBeanIterator() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| processException | back to summary |
|---|---|
| private void processException() | |
| readLineWithPossibleError | back to summary |
|---|---|
| private void readLineWithPossibleError() throws IOException, CsvValidationException | |
| readSingleLine | back to summary |
|---|---|
| private void readSingleLine() | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |