The tJavaFlex component is used to inject code at the start/end of a Job and to transform data transformations for each row.
A common Job using tJavaFlex is generally composed of:
- a tFileInputDelimited component to read data from a text file,
- a tJavaFlex to inject specific code at various moment of the Job processing (start, main or end parts),
- a tLogRow component to print data in the console and processing information based on what the code injection says in the start and/or end part of tJavaFlex.
- In the Palette, slide a tFileInputDelimited , a tJavaFlex and a tLogRow component onto the workspace.
- Connect tFileInputDelimited to tJavaRow and tJavaRow to tLogRow using a Row > Main link.
Set the Basic settings of the tFileInputDelimited
- Double-click on tFileInputDelimited to display its Basic settings. The tFileInputDelimited reads the same text file and use the same schema as in the tJava and tJavaRow example .
- When prompted, click OK to accept the propagation or click afterward on the Sync columns button in the tJavaRow Basic settings view.
Double-click on tJavaRow to display its Basic
settings view. Add the following code in the Start
System.out.println("******The subjob begins to work!******"); int nb_line=0
Add the following code in the Main code area:
Add the following code in the End code area:
System.out.println("The total number of processed data is: "+nb_line); System.out.println("******The subjob finishes!******");Note: This code converts the column names to upper case.
- Execute the Job by pressing F6.