Package com.univocity.parsers.common
Class RetryableErrorHandler<T extends Context>
- java.lang.Object
-
- com.univocity.parsers.common.RetryableErrorHandler<T>
-
- All Implemented Interfaces:
ProcessorErrorHandler<T>
public abstract class RetryableErrorHandler<T extends Context> extends java.lang.Object implements ProcessorErrorHandler<T>
AProcessorErrorHandler
implementation that gives the user a chance to provide a default value for columns that could not be processed due to an exception, through the methodsetDefaultValue(Object)
. This must be called from within the implementation of theProcessorErrorHandler.handleError(DataProcessingException, Object[], Context)
method, and will prevent the record from being discarded. The value provided by the user will be assigned to the problematic input row, at the column defined byDataProcessingException.getColumnIndex()
. NOTE:If the column index is< 0
, then the record can't be salvaged and it will be discarded regardless of the user callingsetDefaultValue(Object)
or not.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
defaultValue
private boolean
skipRecord
-
Constructor Summary
Constructors Constructor Description RetryableErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getDefaultValue()
Returns the default value to be assigned to the problematic column that raised the currentDataProcessingException
.boolean
isRecordSkipped()
Flag indicating whether the current record will be skipped.void
keepRecord()
Ignores theDataProcessingException
and instructs the parser/writer to continue processing the record.(package private) void
prepareToRun()
Prepares this error handler to be executed.void
setDefaultValue(java.lang.Object defaultValue)
Assigns a default value to be assigned to the problematic column that raised the currentDataProcessingException
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.univocity.parsers.common.ProcessorErrorHandler
handleError
-
-
-
-
Method Detail
-
setDefaultValue
public final void setDefaultValue(java.lang.Object defaultValue)
Assigns a default value to be assigned to the problematic column that raised the currentDataProcessingException
. The current column is available from the exception itself, i.e.DataProcessingException.getColumnIndex()
. NOTE:If the column index is< 0
, then the record can't be salvaged and it will be discarded regardless of the user callingsetDefaultValue(Object)
or not.- Parameters:
defaultValue
- the value to be used for the current column. It will be discarded after handling the currentDataProcessingException
.
-
keepRecord
public final void keepRecord()
Ignores theDataProcessingException
and instructs the parser/writer to continue processing the record.
-
getDefaultValue
public final java.lang.Object getDefaultValue()
Returns the default value to be assigned to the problematic column that raised the currentDataProcessingException
. The current column is available from the exception itself, i.e.DataProcessingException.getColumnIndex()
. NOTE:If the column index is< 0
, then the record can't be salvaged and it will be discarded regardless of the user callingsetDefaultValue(Object)
or not.- Returns:
- the value to be used for the current column. It will be discarded after handling the current
DataProcessingException
.
-
prepareToRun
final void prepareToRun()
Prepares this error handler to be executed. This is called automatically by the library prior to invoking methodProcessorErrorHandler.handleError(DataProcessingException, Object[], Context)
-
isRecordSkipped
public final boolean isRecordSkipped()
Flag indicating whether the current record will be skipped. Returnstrue
by default unless the user invokessetDefaultValue(Object)
from within theProcessorErrorHandler.handleError(DataProcessingException, Object[], Context)
method implementation, in which case the current record will continue to be processed.- Returns:
true
if the record originating the currentDataProcessingException
should be skipped, otherwisefalse
-
-