The TalendStringUtil
class contains only one routine
DECODE
that allows you to search a value in a port. You can access the
routine by double-clicking the TalendStringUtil node under the
system routines folder in the Repository tree view.
Routine |
Description |
Syntax |
---|---|---|
DECODE |
Searches a port for a value you specify. If the function finds the value, it
returns a result value, which you define. You can build an unlimited number
of searches within a |
|
Below is an example of how to use the DECODE
routine with a
tJava component. You need to add a tJava
component to a new Job, then enter the following code, which will search the value for
10, in the Code field on the
Basic settings view of the tJava
component.
TalendStringUtil<Integer,String> example = new TalendStringUtil<Integer,String>();
System.out.println(example.DECODE(10, "error", 5, "five", 10, "ten", 15, "fifteen", 20, "twenty"));
Note that you need to create a new object of the TalendStringUtil
type,
and better to use generic type to constrain the input data, then use the object to call the
DECODE
routine.
Press F6 to run the Job. It will return ten
, which
is the result of the value 10.