T - The type of the bean being converted topublic class LineExecutor<T> extends ThreadPoolExecutor
IntolerantThreadPoolExecutor intended for
submitting lines of input to be converted to beans.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicySpliterator.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 |
|---|
LineExecutor(boolean orderedResults,
Locale errorLocale,
CompleteFileReader<T> completeFileReader)
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 |
submitLine(long lineNumber,
MappingStrategy<? extends T> mapper,
CsvToBeanFilter filter,
List<BeanVerifier<T>> verifiers,
String[] line,
CsvExceptionHandler exceptionHandler)
Submit one record for conversion to a bean.
|
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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachRemaining, getComparator, getExactSizeIfKnown, hasCharacteristicsprotected 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 LineExecutor(boolean orderedResults,
Locale errorLocale,
CompleteFileReader<T> completeFileReader)
orderedResults - Whether order should be preserved in the resultserrorLocale - The locale to use for error messagescompleteFileReader - The thread that reads lines of input and feeds the
results to this Executorpublic void prepare()
protected void checkExceptions()
public void submitLine(long lineNumber,
MappingStrategy<? extends T> mapper,
CsvToBeanFilter filter,
List<BeanVerifier<T>> verifiers,
String[] line,
CsvExceptionHandler exceptionHandler)
lineNumber - Which record in the input file is being processedmapper - The mapping strategy to be usedfilter - A filter to remove beans from the running, if necessary.
May be null.verifiers - The list of verifiers to run on beans after creationline - The line of input to be transformed into a beanexceptionHandler - The handler for exceptions thrown during record
processingpublic 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 ExecutorServiceshutdownNow in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorr - t - public Throwable getTerminalException()
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–2025. All rights reserved.