I am using Talend to prepare dataware.
I want to compare the string with the contents of a column using the tMap component and create a variable to store in the DB. The problem is that the ==
operator does not give the right result (Example: row2.recipient == "text"?"text":""
I always get ""
) and if I use .equals
I get errors when executing.
Although tMap expressions are limited to a single line of code, the use of the tMap variables, ternary expressions, and code routines do allow very complex mappings to be handled within a single expression. Explore TALEND Sample Resumes!
It is recommended that multiple tMap components be used to manage complex transformations so that the code is more easily understood. One of the main limitations of tMap is that the output expressions for transformation are limited to just a single line.
Anyways, you can see all the columns are of string type. Drag and drop the Talend tMap, and connect the tFileInputDelimited Main row to tMap. Double-click on the tMap opens the below window. Please click on the + button to add new output.
There are three ways to compare String in Java: The String class equals () method compares the original content of the string. It compares values of string for equality. String class provides the following two methods:
You will get error if row2.recipient is null, and "==" should not be used when comparing strings. Correct syntax would be :
"text".equals(row2.recipient)?"text":""
Then you will prevent NullPointerExceptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With