# TalendStringUtil routine

The TalendStringUtil routine contains only one function DECODE that allows you to search a value in a port.

You can access the function by double-clicking the TalendStringUtil node under the system routines folder in the Repository tree view.

Functions of the TalendStringUtil routineFunctions of the TalendStringUtilTalendStringUtil routine

| Function | Description | Syntax |
| --- | --- | --- |
| DECODE | Searches a<br>port for a value you specify. If the function finds the value, it returns<br>a result value, which you define. You can build an unlimited number of<br>searches within a DECODE function. | TalendStringUtil.DECODE(value, defaultValue, search1, result1[,<br>search2, result2]...)<br><br><ul> <li> <p> <span>value</span>: the value you want to search.</p> </li> <li> <p> <span>defaultValue</span>: the value you want to return if the                                 search does not find a matching value. The default value can be set                                 to <kbd>null</kbd>.</p> </li> <li> <p> <span>search</span>: the value for which you want to search. The                                 search value must have the same datatype as the <kbd>value</kbd> argument.</p> </li> <li> <p> <span>result</span>: the value you want to return if the search                                 finds a matching value.</p> </li> </ul> |

Below is an example of how to use the DECODE function 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.