public class TransformingReader extends ProxyReader
DataEndpoint.State
fieldLineage, recordLineage
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
TransformingReader(DataReader reader)
Accepts the DataReader to transform.
|
TransformingReader(DataReader reader,
DataWriter discardWriter)
Accepts the DataReader to transform and the DataWriter to send discarded records to (due to exception).
|
TransformingReader(DataReader reader,
DataWriter discardWriter,
String discardReasonFieldName)
Accepts the DataReader to transform and the DataWriter to send discarded records to (due to exception).
|
Modifier and Type | Method and Description |
---|---|
TransformingReader |
add(Transformer... transformer) |
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
void |
close()
Indicates that this endpoint has finished reading or writing.
|
Transformer |
get(int index) |
Filter |
getCondition()
Returns the condition under which this transformation applies or
null if it always applies. |
int |
getCount() |
String |
getDiscardReasonFieldName()
Returns the the field in the record to place the description of the transformation that failed along with the exception message.
|
DataWriter |
getDiscardWriter()
Returns the discard sink for bad records or
null if one was not assigned. |
Filter |
getFilter()
Deprecated.
|
protected Record |
interceptRecord(Record record) |
boolean |
isExceptionOnFailure() |
boolean |
isRecordStackTraceInMessage() |
protected void |
onFailure(Record record,
Transformer transformer,
DataException exception,
String message,
Messages messages) |
void |
open()
Makes this endpoint ready for reading or writing.
|
TransformingReader |
setCondition(Filter condition)
Sets the condition under which this transformation applies or
null if it should always be applied. |
TransformingReader |
setCondition(String condition)
Sets the condition under which this transformation applies or
null if it should always be applied. |
TransformingReader |
setExceptionOnFailure(boolean exceptionOnFailure)
Sets the flag to stop processing if an exception is thrown (default) or false if they should be ignored.
|
TransformingReader |
setFilter(Filter filter)
Deprecated.
|
TransformingReader |
setRecordStackTraceInMessage(boolean recordStackTraceInMessage) |
protected boolean |
transformRecord(Record record,
Transformer transformer,
Messages messages) |
available, getNestedReader, map, map, readImpl, setNestedDataReader, setNestedDataReader
addLineage, getBufferSize, getNestedEndpoint, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skip
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
public TransformingReader(DataReader reader, DataWriter discardWriter, String discardReasonFieldName)
reader
- the source reader to transform.discardWriter
- the discard sink for bad records.discardReasonFieldName
- the field in the record to place the description of the transformation that failed along with the exception message.public TransformingReader(DataReader reader, DataWriter discardWriter)
reader
- the source reader to transform.discardWriter
- the discard sink for bad records.public TransformingReader(DataReader reader)
reader
- the source reader to transform.@Deprecated public Filter getFilter()
getCondition()
instead.@Deprecated public TransformingReader setFilter(Filter filter)
setCondition(Filter)
instead.public Filter getCondition()
null
if it always applies.public TransformingReader setCondition(Filter condition)
null
if it should always be applied.public TransformingReader setCondition(String condition)
null
if it should always be applied.public boolean isExceptionOnFailure()
public TransformingReader setExceptionOnFailure(boolean exceptionOnFailure)
public boolean isRecordStackTraceInMessage()
public TransformingReader setRecordStackTraceInMessage(boolean recordStackTraceInMessage)
public TransformingReader add(Transformer... transformer)
public int getCount()
public Transformer get(int index)
public DataWriter getDiscardWriter()
null
if one was not assigned.public String getDiscardReasonFieldName()
public void open() throws DataException
DataEndpoint
open
in class ProxyReader
DataException
public void close() throws DataException
DataEndpoint
close
in class ProxyReader
DataException
protected Record interceptRecord(Record record) throws Throwable
interceptRecord
in class ProxyReader
Throwable
protected boolean transformRecord(Record record, Transformer transformer, Messages messages)
protected void onFailure(Record record, Transformer transformer, DataException exception, String message, Messages messages)
public DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class ProxyReader
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.