public abstract class RetryableErrorHandler<T extends Context> extends Object implements ProcessorErrorHandler<T>
ProcessorErrorHandler
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 method setDefaultValue(Object)
.
This must be called from within the implementation of the
ProcessorErrorHandler.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 by
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 calling setDefaultValue(Object)
or not.DataProcessingException
,
TextParsingException
,
AbstractParser
,
AbstractWriter
,
CommonSettings
,
Context
Constructor and Description |
---|
RetryableErrorHandler() |
Modifier and Type | Method and Description |
---|---|
Object |
getDefaultValue()
Returns the default value to be assigned to the problematic column that raised the current
DataProcessingException . |
boolean |
isRecordSkipped()
Flag indicating whether the current record will be skipped.
|
void |
keepRecord()
Ignores the
DataProcessingException and instructs the parser/writer to continue processing the record. |
void |
setDefaultValue(Object defaultValue)
Assigns a default value to be assigned to the problematic column that raised the current
DataProcessingException . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handleError
public final void setDefaultValue(Object defaultValue)
DataProcessingException
.
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 calling setDefaultValue(Object)
or not.defaultValue
- the value to be used for the current column. It will be discarded after handling the current
DataProcessingException
.public final void keepRecord()
DataProcessingException
and instructs the parser/writer to continue processing the record.public final Object getDefaultValue()
DataProcessingException
.
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 calling setDefaultValue(Object)
or not.DataProcessingException
.public final boolean isRecordSkipped()
true
by default unless
the user invokes setDefaultValue(Object)
from within the ProcessorErrorHandler.handleError(DataProcessingException, Object[], Context)
method implementation, in which case the current record will continue to be processed.true
if the record originating the current DataProcessingException
should be skipped,
otherwise false
Copyright © 2017 uniVocity Software Pty Ltd. All rights reserved.