tJavaRow example - Cloud - 8.0

Talend Job Script Reference Guide

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend CommandLine
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2024-02-22

In the following example, the tJavaRow component, labeled validator, will execute a piece of Java code to validate the format of the E-mail address from each row of the input data flow. To execute the Java code, the required Java classes need to be imported.

	setSettings {
		CODE : "String email = input_row.email;
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern = compiler.compile(\"^[\\\\w_.-]+@[\\\\w_.-]+\\\\.[\\\\w]+$\");

if (!matcher.matches(email, pattern)) {
	System.out.println(email + \" : \" + \"invalid\");
	}
	else
	System.out.println(email + \" : \" + \"valid\");",
		IMPORT : "import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Pattern;",
		LABEL : "validator"
	}
}