T
- The type of the bean being convertedpublic class BeanExecutor<T> extends ThreadPoolExecutor
IntolerantThreadPoolExecutor
intended for
submitting beans to be converted to String
s for writing.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Spliterator.OfDouble, Spliterator.OfInt, Spliterator.OfLong, Spliterator.OfPrimitive<T,T_CONS,T_SPLITR extends Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>>
Modifier and Type | Field and Description |
---|---|
protected com.opencsv.bean.concurrent.AccumulateCsvResults<T> |
accumulateThread
A separate thread that accumulates and orders results.
|
protected Locale |
errorLocale
The locale for error messages.
|
protected SortedSet<Long> |
expectedRecords
A list of the ordinals of data records still to be expected by the accumulator.
|
protected BlockingQueue<OrderedObject<T>> |
resultQueue
A queue of the beans created.
|
protected BlockingQueue<OrderedObject<CsvException>> |
thrownExceptionsQueue
A queue of exceptions thrown by threads during processing.
|
CONCURRENT, DISTINCT, IMMUTABLE, NONNULL, ORDERED, SIZED, SORTED, SUBSIZED
Constructor and Description |
---|
BeanExecutor(boolean orderedResults,
Locale errorLocale)
The only constructor available for this class.
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t)
Shuts the Executor down if the thread ended in an exception.
|
int |
characteristics() |
protected void |
checkExceptions()
Checks whether exceptions are available that should halt processing.
|
void |
complete()
Sends a signal to the Executor that it should shut down once all threads
have completed.
|
long |
estimateSize() |
List<CsvException> |
getCapturedExceptions()
Returns exceptions captured during the conversion process if
the conversion process was set not to propagate these errors
up the call stack.
|
Throwable |
getTerminalException()
If an unrecoverable exception was thrown during processing, it can be
retrieved here.
|
void |
prepare()
Prepares this Executor to receive jobs.
|
List<Runnable> |
shutdownNow() |
void |
submitBean(long lineNumber,
MappingStrategy<T> mappingStrategy,
T bean,
CsvExceptionHandler exceptionHandler)
Submit one bean for conversion.
|
boolean |
tryAdvance(Consumer<? super T> action) |
Spliterator<T> |
trySplit() |
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, terminated, toString
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristics
protected final BlockingQueue<OrderedObject<T>> resultQueue
protected final BlockingQueue<OrderedObject<CsvException>> thrownExceptionsQueue
protected com.opencsv.bean.concurrent.AccumulateCsvResults<T> accumulateThread
protected final SortedSet<Long> expectedRecords
protected final Locale errorLocale
public BeanExecutor(boolean orderedResults, Locale errorLocale)
orderedResults
- Whether order should be preserved in the resultserrorLocale
- The locale to use for error messagespublic void submitBean(long lineNumber, MappingStrategy<T> mappingStrategy, T bean, CsvExceptionHandler exceptionHandler)
lineNumber
- Which record in the output file is being processedmappingStrategy
- The mapping strategy to be usedbean
- The bean to be transformed into a line of outputexceptionHandler
- The handler for exceptions thrown during record
processingpublic void prepare()
public void complete() throws InterruptedException
InterruptedException
- If the current thread is interrupted while
waiting. Shouldn't be thrown, since the Executor
waits indefinitely for all threads to end.RejectedExecutionException
- If an exception during processing
forced this Executor to shut down.public List<CsvException> getCapturedExceptions()
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
shutdownNow
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
r
- t
- public Throwable getTerminalException()
protected void checkExceptions()
public boolean tryAdvance(Consumer<? super T> action)
tryAdvance
in interface Spliterator<T>
public Spliterator<T> trySplit()
trySplit
in interface Spliterator<T>
public long estimateSize()
estimateSize
in interface Spliterator<T>
public int characteristics()
characteristics
in interface Spliterator<T>
Copyright © 2005–2023. All rights reserved.