Example - 6.5

Talend Job Script Reference Guide

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data
Talend Big Data Platform
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
task
Design and Development > Designing Jobs
EnrichPlatform
Talend CommandLine
Talend Studio

In the following example, the tJavaRow component, labelled 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"
	}
}