Skip to main content

tJavaRow example

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"
	}
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!