global variables in java

Highlighted
One Star

global variables in java

Hello Smiley Happy
I have a perl job in which I use a tPerlRow composant in which I wrote :
$output_row = $input_row;
$output_row = $_globals{line};
$_globals{line} = $input_row;

Now I want to do the same job but in java... what should I put in my tJavaRow ? What is the equivalent of $_globals ?
Thank you Smiley Happy
One Star

Re: global variables in java

Hi,
is globals the global map or a context variable?
In the first case:
output_row.line = input_row.line;
output_row.previous_line = (String)globalMap.get("line");
globalMap.set("line", input_row.line);

If it is a context variable (this would make more sense):
output_row.line = input_row.line;
output_row.previous_line = context.line;
context.line= input_row.line;

Bye
Volker
One Star

Re: global variables in java

Hello,
Actually I was using the job Plegall detailed in 5784
I think that it is a global map variable, but
globalMap.set("line", input_row.line);

won't work.
Error : "The method set(String, String) is undefined for the type Map<String,Object>"
Do you have an idea of what I could do to fix this ?
Thank you ! Smiley Happy
One Star

Re: global variables in java

Hi again !
OK, it's working, I just had to change the globalMap.set into a globalMap.put.
output_row.line = input_row.line;
output_row.previous_line = (String)globalMap.get("line");
globalMap.put("line", input_row.line);

Thanks again Volker ! Smiley Happy
One Star

Re: global variables in java

Yes,
you are right. Thanks for correction.
Bye
Volker

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog