Class FieldTransformer
java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
com.northconcepts.datapipeline.transform.FieldTransformer
- Direct Known Subclasses:
BasicFieldTransformer
See
FieldPath for supported field name expressions.-
Constructor Summary
ConstructorsConstructorDescriptionFieldTransformer(String name) FieldTransformer(String... names) FieldTransformer(Collection<String> names) -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this transformer's details to an exception raised by its host reader or writer; returns the same exception.Returns the field being transformed or null if the field last looked up is missing from the record.Returns the record being transformed, for use intransformField(Field).getName()Returns the name of the field this transformer applies to if only one field was specified, otherwisenullif multiple fields.getNames()String[]Returns the value a field receives when transforming it throws, or null if none was set.booleanReturns true ifsetValueOnException(Object)was called, even with null.booleanIndicates if an exception should be thrown if the source field is missing (default to true).setThrowExceptionOnMissingField(boolean throwExceptionOnMissingField) Indicates if an exception should be thrown if the source field is missing (default to true).setValueOnException(Object valueOnException) Sets the value a field receives when transforming it throws, instead of failing; null is a valid value.toString()booleanApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.protected abstract voidtransformField(Field field) Transforms the given field in place; called for each named field found in the record.Methods inherited from class com.northconcepts.datapipeline.transform.Transformer
close, geEndpoint, getEndpoint, getReader, getWriter, of, open, setWriter
-
Constructor Details
-
FieldTransformer
-
FieldTransformer
-
FieldTransformer
-
-
Method Details
-
getName
Returns the name of the field this transformer applies to if only one field was specified, otherwisenullif multiple fields.- See Also:
-
getNames
-
getNamesAsStrings
-
isThrowExceptionOnMissingField
public boolean isThrowExceptionOnMissingField()Indicates if an exception should be thrown if the source field is missing (default to true). -
setThrowExceptionOnMissingField
Indicates if an exception should be thrown if the source field is missing (default to true). -
getCurrentRecord
Returns the record being transformed, for use intransformField(Field). -
getCurrentField
Returns the field being transformed or null if the field last looked up is missing from the record. -
setValueOnException
Sets the value a field receives when transforming it throws, instead of failing; null is a valid value. -
getValueOnException
Returns the value a field receives when transforming it throws, or null if none was set. -
hasValueOnException
public boolean hasValueOnException()Returns true ifsetValueOnException(Object)was called, even with null. -
transform
Description copied from class:TransformerApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Contract for subclasses (see also
docs/authoring/Transformer.md):- Mutate
recordin place as needed. - Return
trueto keep the record in the pipeline. - Return
falseto drop the record (the host routes it to a discard writer if one is configured, otherwise it disappears). - Throw to fail (or route to a discard writer, depending on host configuration).
- Do not call
incrementRecordCount()on the host endpoint; the host handles it.
- Specified by:
transformin classTransformer- Throws:
Throwable
- Mutate
-
transformField
Transforms the given field in place; called for each named field found in the record.- Throws:
Throwable
-
toString
-
addExceptionProperties
Description copied from class:TransformerAdds this transformer's details to an exception raised by its host reader or writer; returns the same exception.- Overrides:
addExceptionPropertiesin classTransformer
-