Class ValidatingReader
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataReader
com.northconcepts.datapipeline.core.ProxyReader
com.northconcepts.datapipeline.filter.FilteringReader
com.northconcepts.datapipeline.validate.ValidatingReader
A proxy that validates records by applying a set of filters.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
Fields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionValidatingReader(DataReader reader) Creates a reader that throws an exception for the first record failing validation.ValidatingReader(DataReader reader, DataWriter discardWriter) Accepts the DataReader to validate and the DataWriter to send discarded records to.ValidatingReader(DataReader reader, DataWriter discardWriter, String discardReasonFieldName) Accepts the DataReader to validate and the DataWriter to send discarded records to. -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.protected RecordHandles a record rejected byfilter; writes it to the discard writer (adding the discard reason field if configured) and returns null so it is dropped.booleanIndicates if a record failing validation throws an exception instead of being discarded with a warning (defaults to true unless a discard writer is set).booleanIndicates if the warning recorded for each discarded record captures a stack trace (defaults to true).setExceptionOnFailure(boolean exceptionOnFailure) Indicates if a record failing validation throws an exception instead of being discarded with a warning; cannot be turned on while a discard writer is set.setRecordStackTraceInMessage(boolean recordStackTraceInMessage) Indicates if the warning recorded for each discarded record captures a stack trace (defaults to true).Methods inherited from class com.northconcepts.datapipeline.filter.FilteringReader
add, close, get, getCount, getCurrentFilter, getDiscardReasonFieldName, getDiscardWriter, interceptRecord, open, remove, removeAllMethods inherited from class com.northconcepts.datapipeline.core.ProxyReader
available, getNestedReader, map, map, readImpl, setNestedDataReader, setNestedDataReaderMethods inherited from class com.northconcepts.datapipeline.core.DataReader
addLineage, getBufferSize, getNestedEndpoint, getReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Constructor Details
-
ValidatingReader
Accepts the DataReader to validate and the DataWriter to send discarded records to. The exceptionOnFailure flag will be turned off if discardWriter contains a non-null value. Attempting to turn exceptionOnFailure on while a discardWriter is present will result in an exception.- Parameters:
reader- the source reader to filter.discardWriter- the discard sink for disallowed records.discardReasonFieldName- the field in the record to place the description of the filter that disallowed it ornullif one should not be added.
-
ValidatingReader
Accepts the DataReader to validate and the DataWriter to send discarded records to. The exceptionOnFailure flag will be turned off if discardWriter contains a non-null value. Attempting to turn exceptionOnFailure on while a discardWriter is present will result in an exception.- Parameters:
reader- the source reader to filter.discardWriter- the discard sink for disallowed records.
-
ValidatingReader
Creates a reader that throws an exception for the first record failing validation.
-
-
Method Details
-
isExceptionOnFailure
public boolean isExceptionOnFailure()Indicates if a record failing validation throws an exception instead of being discarded with a warning (defaults to true unless a discard writer is set). -
setExceptionOnFailure
Indicates if a record failing validation throws an exception instead of being discarded with a warning; cannot be turned on while a discard writer is set. -
isRecordStackTraceInMessage
public boolean isRecordStackTraceInMessage()Indicates if the warning recorded for each discarded record captures a stack trace (defaults to true). -
setRecordStackTraceInMessage
Indicates if the warning recorded for each discarded record captures a stack trace (defaults to true). -
discard
Description copied from class:FilteringReaderHandles a record rejected byfilter; writes it to the discard writer (adding the discard reason field if configured) and returns null so it is dropped.- Overrides:
discardin classFilteringReader
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classFilteringReader
-