public class TransformingWriter extends ProxyWriter
DataEndpoint.State
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
TransformingWriter(DataWriter writer)
Accepts the target DataWriter of the transform.
|
TransformingWriter(DataWriter writer,
DataWriter discardWriter)
Accepts the target DataWriter of the transform and the DataWriter to send discarded records to (due to exception).
|
TransformingWriter(DataWriter writer,
DataWriter discardWriter,
String discardReasonFieldName)
Accepts the target DataWriter of the transform and the DataWriter to send discarded records to (due to exception).
|
Modifier and Type | Method and Description |
---|---|
TransformingWriter |
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. |
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.
|
TransformingWriter |
setCondition(Filter condition)
Sets the condition under which this transformation applies or
null if it should always be applied. |
TransformingWriter |
setExceptionOnFailure(boolean exceptionOnFailure)
Sets the flag to stop processing if an exception is thrown (default) or false if they should be ignored.
|
TransformingWriter |
setRecordStackTraceInMessage(boolean recordStackTraceInMessage) |
protected boolean |
transformRecord(Record record,
Transformer transformer,
Messages messages) |
available, getNestedWriter, map, map, setNestedDataWriter, setNestedDataWriter, writeImpl
getNestedEndpoint, getRootEndpoint, getRootWriter, write
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 TransformingWriter(DataWriter writer, DataWriter discardWriter, String discardReasonFieldName)
writer
- the target writer of the 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 TransformingWriter(DataWriter writer, DataWriter discardWriter)
writer
- the target writer of the transform.discardWriter
- the discard sink for bad records.public TransformingWriter(DataWriter writer)
writer
- the target writer of the transform.public Filter getCondition()
null
if it always applies.public TransformingWriter setCondition(Filter condition)
null
if it should always be applied.public boolean isExceptionOnFailure()
public TransformingWriter setExceptionOnFailure(boolean exceptionOnFailure)
public boolean isRecordStackTraceInMessage()
public TransformingWriter setRecordStackTraceInMessage(boolean recordStackTraceInMessage)
public TransformingWriter 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 ProxyWriter
DataException
public void close() throws DataException
DataEndpoint
close
in class ProxyWriter
DataException
protected Record interceptRecord(Record record) throws Throwable
interceptRecord
in class ProxyWriter
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 ProxyWriter
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.