Transformations -- Overview

This section provides instructions on how to use Transform4J to accomplish data transformations.

Transformations extend class Transformer. In the Transform4J world, transformations (e.g. extensions of class Transformer) have one data source and one data target. In a Transform4J world, "transformations" with multiple sources and targets are written in a series of smaller transformations that each have one source and one target (see Composite Transformations).

Transform4J provides a library of standard transformations out of the box for activities such as aggregating and sorting data. It's expected that this list of standard transformations will grow over time. (see Standard Transformations)

Additional sections:

  • Next section
  • A Simple Example

    This simple transformation combines the first name, last name, and middle initial to the format "Last, First I". Real-life transformations will have more custom logic than this, but you get the idea.

    public class MyTranformation extends Transformer<DataRecord> {
    	protected void process(DataRecord input) {
    		DataRecord output = new DataRecord();
    		// Insert logic to derive the full name here
    		StringBuffer nameBuffer = new StringBuffer(input.getValueAsString("lastName"));
    		nameBuffer.append(", ");
    		String middleInitial = input.getValueAsString("middleInitial");
    		if (middleInitial != null) {
    			nameBuffer.append(" ");
    		// Set the output with the full name and write it.
    		output.setValue("fullName", nameBuffer.toString());		

    See Transformer javadoc.

    Next section.