Clover ETL Transformation Language functions

Listed below are all Clover ETL TL language functions which are part of the standard release.

Conversion functions

base64byte

(since 2.4)

Converts string containing BASE64 encoded data into binary representation - bytearray.

Syntax

bytearray base64byte(string src);

Attributes

Return type

Exception

Example

  string stringBase='aGVsbG93b3JsZA==';
  bytearray bytes=base64byte(stringBase);

bits2str

Converts an array of bits to a string. It is a counterpart of the str2bits() function. The function converts each byte(8bits) of byte array to 8 characters. The bit 1 is character '1', bit 0 is character '0'. The first character represents the lowest bit (i.e.: 2 = '010000000').

Syntax

string bits2str(byte arg);

Attributes

Return type

Exception

Example

  bits2str(str2bits("0010001010100010")) returns '0010001010100010'
  bits2str(str2bits("ab1cde1f1g1hij1")) returns  '0010001010100010'

bool2num

(since 2.4)

Converts boolean to requested numeric type, true is converted to 1 and false to 0;

Syntax

numeric bool2num(boolean from);
numeric bool2num(boolean from, type type);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 22 : bool2num - cant't convert to DATE

Example

  decimal(20,10) mydec = bool2num(false,decimal) returns 0E-10

byte2base64

Converts an array of bytes to its BASE64 representation. It is a counterpart of the base64byte() function.

Syntax

string byte2base64(bytearray arg);

Attributes

Return type

Example

  byte2base64(helloworld) returns 'aGVsbG93b3JsZA=='

byte2hex

Converts an array of bytes to its hexadecimal representation. It is a counterpart of the hex2byte() function. It returns 2 characters for each byte of the byte array (e.g.: [68, 69] = [0100 0100, 0100 0101] = 4445).

Syntax

string byte2hex(bytearray arg);

Attributes

Return type

Example

  byte2hex(a) returns 61

date2long

(since 2.4)

Converts date to long representing the number of milliseconds since January 1, 1970, 00:00:00 GMT.

Syntax

long date2long(date from);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 1 : date2long - wrong type of literals

Example

  date2long($Born)

date2num

Returns value of given “field” (for month the value is from range 0-11). Remember that time units (“field”) must be specified as constants in the function! They can neither be received as field values nor be defined as variables.

Syntax

int date2num(date date_arg, enum field);

Attributes

  • date_arg – date
  • field – one of: year, month, week, day, hour, minute, second, millisec.

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : date2num - no Date expression if first argument is not of type date or has null value)

Example

  d=2001-12-20;
  date2num(d,month) returns 11


date2str

Returns string representation of “date” in format given by “pattern”. For complete rules see documentation of java.text.SimpleDateFormat.

Syntax

string date2str(date date,string pattern);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : date2str - wrong type of literal – if “date” is not of type date or has null value)
  • IllegalArgumentException(Illegal pattern – if “pattern” contains not allowed signs)

Example

  date2str(2002-12-24, 'dd.MM.yyyy') returns '24.12.2002'


hex2byte

Converts a string in hexadecimal representation to an array of bytes. It is a counterpart of the byte2hex() function. It returns a byte for each 2 hex(0-9a-f) characters (e.g.: '4445' = [0100 0100, 0100 0101] = [68, 69]).

Syntax

bytearray hex2byte(string arg);

Attributes

Return type

Example

  hex2byte('61') returns a

long2date

(since 2.4)

Converts long to date and sets it to a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

Syntax

date long2date(long from);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 21 : Number format error [<INTEGER_LITERAL>] : Unrecognized value: 12123431274515793579 when number is greater then Long.MAX_VALUE
  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 1 : long2date - wrong type of literals

Example

  long2date(1212343127451l) returns Sun Jun 01 19:58:47 CEST 2008;

num2bool

(since 2.4)

Converts numeric representing 0 (false) or 1 (true) to boolean.

Syntax

boolean num2bool(numeric from);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 16 : num2bool - can't convert “1.1” to BOOLEAN
  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 16 : num2bool - wrong type of literals
    arg[0] org.jetel.interpreter.data.TLDateValue “Fri Feb 29 10:28:20 CET 2008”

Example

  boolean mybool = num2bool(1);

num2num

(since 2.4)

Converts numeric to another numeric. Conversion is successful if and only if requested value can be converted to requested type without any information loss.

Syntax

numeric num2num(numeric from, type type);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 27 : num2num - can't convert “32.54” to INTEGER

Example

  int i; double d =32; i = num2num(d,int);

num2str

Returns string representation of “num” in “radix” based system or (since 2.6.1 ver.) formatted due to given format.

Syntax

string num2str(numeric num);
string num2str(numeric num, int radix);
string num2str(numeric num, string format);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : num2str - wrong type of literal – if num is not of one of numeric types or has null value)

Example

  num2str(2.5e-1) returns '0.25'
  num2str(10) returns '10'
  num2str(10, 8) returns '12'
  num2str(1.0000) returns '1.0'
  num2str(1247,'¤###,000.00') returns '$1,247.00'


str2bits

Converts a string to an array of bits. It is a counterpart of the bits2str function. The function convertes each 8 characters to 1B (8bits). The character '1' is 0, other characters are 0 in the byte array. The first character represents the lowest bit (i.e.: '01000000' = 2). If the string size is shorter than 8, the rest of characters are '0'.

Syntax

bytearray str2bits(string arg);

Attributes

Return type

Exception

Example

  str2bits("001000101010001") returns [68, 69]   // byte array
  str2bits("ab1cde1f1g1hij1k") returns [68, 69]   // byte array

str2bool

(since 2.4)

Converts string to boolean. For successful conversion string must match to default "true" or "false" format.

Syntax

boolean str2bool(string from);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 42 column 1 : str2bool - can't convert “tru” to BOOLEAN

Example

  boolean mybool=str2bool('true');
  boolean mybool=str2bool('0');

str2date

Returns date which has string representation given by “pattern”.

Syntax

date str2date(string date, string pattern);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException: Interpreter runtime exception : str2date - wrong type of literal – if “date” is not of type string or has null value)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : str2date - can't convert … - if “date” does not match “pattern”)

Example

  str2date('20070101', 'yyyyMMdd') returns date

From ver. 2.4

Returns date which has string representation given by pattern and locale. With lenient argument set to true, convertor may use heuristics to interpret inputs that do not precisely match this object's format. With strict converting, inputs must match this object's format. First two arguments are necessary; when there are only three arguments, third argument is treated as locale if it is of type string or as lenient if it is of type bool.

Syntax

date str2date(string date, string pattern, string locale, bool lenient);

Attributes

Example

  str2date('20July    2000','ddMMMyyyy','en.GB') returns date
  str2date('20-15-2000','dd-MM-yyyy','en.GB',true) returns date
  str2date('20-15-2000','dd-MM-yyyy','en.GB',false) throws TransformLangExecutorRuntimeException: 
                    Interpreter runtime exception : str2date - can't convert ...


str2num

Parses the string argument as a signed number in the radix specified by the third argument. Default return value is int and radix is 10. For types other then int, second argument must be given.

Syntax

number str2num(string str);
type str2num(string str, enum type);
type str2num(string str, enum type, number radix);
type str2num(string str, enum type, string pattern);
type str2num(string str, enum type, string pattern, string locale);

Attributes

Return type

  • depends on type param.

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : str2num - wrong type of literal – if str is not of the type string or has null value)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : str2num - can't convert … - if str is not a representation of number or if trying to convert not integer digit to integer type (int, long))
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : str2num - can't convert string to decimal number using specified radix - if type is decimal and radix is not 10.
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : str2num - can't convert string to number/double number using specified radix - if type is double and radix is not 10 or 16. However, radix does not need to be specified as it is guessed according to the form of the string (as mentioned above).

Example

  decimal n = str2num('2.5e-1',decimal) returns n = 0.25
  int m = str2num('2.5e-1') 
      throws TransformLangExecutorRuntimeException: Interpreter runtime exception : str2num - can't convert "2.5e-1"
  n = str2num("1,005.46$",decimal,"#,###.00¤","en.US")


to_string

(since 2.4)

Returns string representation of argument.

Syntax

string to_string(any_type from);

Attributes

Return type

Exception

Example

  to_string(myVariable);
  to_string($Born);


get_field_name

(since 2.9)

Returns name of i-th (0 based) field of passed-in record. If the field with given index doesn't exist, empty string is returned.

Syntax

string get_field_name(record record, numeric index);

Attributes

  • record – record
  • index – numeric - field index (starting from 0)

Return type

Exception Interpreter runtime exception on line 7 column 34 : get_field_name - - wrong type of literals - if the 1st argument is not record and the 2nd one is not numeric

Example

  get_field_name(@0,0); - returns name of 0th field from 0th input


get_field_type

(since 2.9)

Returns data type of i-th (0 based) field of passed-in record. If the field with given index doesn't exist, empty string is returned.

Syntax

string get_field_name(record record, numeric index);

Attributes

  • record – record
  • index – numeric - field index (starting from 0)

Return type

Exception Interpreter runtime exception on line 7 column 34 : get_field_type - - wrong type of literals - if the 1st argument is not record and the 2nd one is not numeric

Example

  get_field_type(@input,1); - returns type of 1th field from input data record with "input" record name


try_convert

(since 2.4)

Tries to convert variable from one type to another. It returns either the converted value (on successful conversion) or a null value on failure. Third argument is optional and is used when converting from/to string.

Syntax

any try_convert(any from, type targetType, string format);

Attributes

Return type

Exception

Example

  string stringNo='12';
  try_convert(stringNo, int) returns 12
  stringNo='15a';
  try_convert(stringNo, int) returns null
  date d;
  d=try_convert('20.9.2007',date,'dd.MM.yyyy');


Date functions

dateadd

returns a date later (earlier) from “start” date for “amount” of time units described by “field”. Remember that time units must be specified as constants in the function! They can neither be received as field values nor be defined as variables.

Syntax

date dateadd(date start, numeric amount, enum field);

Attributes

  • start – date
  • amount – numeric
  • field – one of: year, month, week, day, hour, minute, second, millisec

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : dateadd - no Date expression - if first argument is not of type date or has null value)
  • TransformLangExecutorRuntimeException(Interpreter runtime exception : dateadd – if second argument is not of one of numeric types or has null value)

Example

  dateadd(2006-01-01, 14, month) returns 2007-03-01
  dateadd(2006-01-30, -2, day) returns 2006-01-28


datediff

Returns difference between two dates in time units described by “field”. If “later” is after “earlier” the result is positive else it is negative. Remember that time units must be specified as constants in the function! They can neither be received as field values nor be defined as variables.

Syntax

int datediff(date later, date earlier, enum field);

Attributes

  • later – date
  • earlier – date
  • field – one of: year, month, day, week, hour, minute, second, millisec

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : datediff - no Date expression - if first or second argument is not of type date or has null value)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : datediff - wrong difference unit – if field is millisec or millisec)

Example

  datediff(1946-04-01, 2006-01-01, year) returns -60


random_date

(since 2.7)

Returns a random date and time. The date and time can even take the values of the specified arguments “from” and/or “to”. Remember, however, that each date (like for example: 2002.03.29) represents the beginning of the date. In other words, it equals to the same date in which hours, minutes, seconds, and milliseconds are 0. (In this case, 2002.03.29 00:00:00 000). For this reason, if you want that such a date (2002.03.29) can be returned by the random_date() function, you should set the “to” margin to the next day (2002.03.30.).

Syntax

date random_date(date from, date to);
date random_date(long from, long to);
date random_date(date from, date to, long randomSeed);
date random_date(long from, long to, long randomSeed);
date random_date(string from, string to, string format);
date random_date(string from, string to, string format, string locale);
date random_date(string from, string to, string format, long randomSeed);
date random_date(string from, string to, string format, string locale, long randomSeed);

Attributes

  • from - date/long - start date
  • to - date/long - end date
  • randomSeed - long - optional - it specifies a random series

or

  • from - string - start date
  • to - string - start date
  • format - string - string date format (SimpleDateFormat) for string representation
  • locale - string - optional - it defines national rules for string parsing
  • randomSeed - long - optional - it specifies a random series

Return type

Exception

Example

  random_date(today(), dateadd(today(),20,day))
  random_date(today(), dateadd(today(),20,day),0)
  random_date("2009-01-01", "2009-02-01","yyyy-MM-dd")
  random_date("2009-01-01", "2009-02-01","yyyy-MM-dd",0)
  random_date("2009-01-01", "2009-02-01","yyyy-MM-dd","US")
  random_date("2009-01-01", "2009-02-01","yyyy-MM-dd","US",0)


today

Returns current date and time.

Syntax

date today();

Attributes

Return type

Exception

Example

  today() returns date


trunc

Returns truncation of “arg”. For numeric types it is long part of “arg”, for date type it is the date with the same year,month and day, but hour, minute, second and millisecond are set to zero values. In case of list or map parameter, the effect is emptying the list or map passed in and the return value is null.

Syntax

long trunc(numeric arg);
date trunc(date arg);
trunc(list arg);
trunc(map arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : trunc - wrong type of literal(s) – if argument is not one of the listed above)

Example

  trunc(1.54) returns 1
 
  list mylist; mylist[]=1; mylist[]=2;
  trunc(mylist); returns null, length(mylist)==0;


trunc_date

Returns the date with the same hour, minute, second and millisecond, but year, month and day are set to zero values. Zero date value is 0001-01-01.

Syntax

date trunc_date(date arg);

Attributes

Return type


Math functions

abs

Returns absolute value of “arg”.

Syntax

number abs(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : abs - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  abs(-2.3) returns 2.3


bit_and

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes their integer parts and returns a long value. This long is the result of bitwise “and”.

Syntax

long bit_and(numerictype arg1,numerictype arg2);

Attributes

Return type

Example

  bit_and(11,7) returns 3;


bit_is_set

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes their integer parts and returns a boolean true or false if the bit in bitwise representation of the first argument that is located on the position specified by the Index is 1 or 0, respectively. Bits are indexed starting from 0 from the right side of the bitwise representation of the number. Thus, if Index is 0, it corrrespond to the first bit on the right side.

Syntax

boolean bit_is_set(numerictype arg,numerictype Index);

Attributes

Return type

Example

  bit_is_set(11,0) returns true, bit_is_set(11,1) returns true, bit_is_set(11,2) returns false;


bit_lshift

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes the integer parts of both of them and adds the number of bits (each is set to 0) that is specified as the second argument to the right side of the bitwise representation of the first argument.

Syntax

long bit_lshift(numerictype arg,numerictype Shift);

Attributes

Return type

Example

  bit_lshift(11,1) returns 22;


bit_or

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes their integer parts and returns a long value. This long is the result of bitwise “or”.

Syntax

long bit_or(numerictype arg1,numerictype arg2);

Attributes

Return type

Example

  bit_or(11,7) returns 15;


bit_rshift

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes the integer parts of both of them and removes the number of bits that is specified as the second argument from the right side of the bitwise representation of the first argument.

Syntax

long bit_rshift(numerictype arg,numerictype Shift);

Attributes

Return type

Example

  bit_rshift(11,1) returns 5;


bit_set

(since 2.7)

The function accepts three arguments. The first two are of any numeric data type. The third is boolean. It takes the integer parts of the first two arguments and sets the bit in bitwise representation of the first argument that is located on the position specified by the Index to 1 or 0, if the third argument is true or false, respectively, and returns the number as long value. Bits are indexed starting from 0 from the right side of the bitwise representation of the number. Thus, if Index is 0, it corrrespond to the first bit on the right side.

Syntax

long bit_set(numerictype arg,numerictype Index, boolean SetBitTo1);

Attributes

Return type

Example

  bit_set(11,0,false) returns 10, bit_set(11,1,false) returns 9, bit_set(11,2,true) returns 15;


bit_xor

(since 2.7)

The function accepts two arguments. Both are of any numeric data type. It takes their integer parts and returns a long value. This long is the result of bitwise “exclusive or”.

Syntax

long bit_xor(numerictype arg1,numerictype arg2);

Attributes

Return type

Example

  bit_xor(11,7) returns 12;


e

The function returns e. The double value that is closer than any other to e, the base of the natural logarithms.

Syntax

number e();

Attributes

Return type

Exception

Example

  e() returns 2.7182818284590452354;


exp

Returns exponent of “arg”.

Syntax

number exp(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : exp - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  exp(1) returns e^1 = 2.71828182845905


log

Returns natural logarithm (base e) of “arg”, -Infinity if “arg” equals zero or NaN if “arg” is less then zero.

Syntax

number log(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : log - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  // e is euler number
  log(e) returns 1;


log10

Returns base 10 logarithm of “arg”, -Infinity if “arg” equals zero or NaN if “arg” is less then zero.

Syntax

number log10(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : log10 - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  log10(10) returns 1;


pi

The function returns π. The double value that is closer than any other to π, the ratio of the circumference of a circle to its diameter.

Syntax

number pi();

Attributes

Return type

Exception

Example

  pi() returns 3.14159265358979323846;


pow

Returns “base” risen to “exp”-power.

Syntax

number pow(numeric base, numeric exp);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : pow - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  pow(10, 2) returns 100;


random

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. The general contract is that one double value, chosen (approximately) uniformly from the range 0.0d (inclusive) to 1.0d (exclusive), is pseudorandomly generated and returned. All 2^53 possible float values of the form m x 2^-53, where m is a positive integer less than 2^53, are produced with (approximately) equal probability. The method is implemented by class Random.

Syntax

number random();
number random(long randomSeed);

Attributes

  • randomSeed - long - optional - it defines a random series

Return type

Exception

Example

  print_err('Random number: '+random()) prints out: Random number: 0.2288097749720398 ;



random_boolean

(since 2.7)

Returns the pseudorandom, uniformly distributed boolean value from this random number generator's sequence. The general contract is that one boolean value is pseudorandomly generated and returned. The values true and false are produced with (approximately) equal probability. The method is implemented by class Random.

Syntax

boolean random_boolean();
boolean random_boolean(long randomSeed);

Attributes

  • randomSeed - long - optional - it defines a random series

Return type

Exception

Example

  print_err('Random boolean: '+random_boolean()) prints out: Random boolean: true ;


random_gaussian

(since 2.7)

Returns a double value with gaussian distribution. The general contract is that one double value, chosen from (approximately) the usual normal distribution with mean 0.0 and standard deviation 1.0, is pseudorandomly generated and returned. The method is implemented by class Random.

Syntax

number random_gaussian();
number random_gaussian(long randomSeed);

Attributes

  • randomSeed - long - optional - it defines a random series

Return type

Exception

Example

  print_err('Random number: '+random_gaussian()) prints out: Random number: -1.051630836818732 ;


random_int

(since 2.7)

Returns an integer value. Returns the pseudorandom, uniformly distributed int value from this random number generator's sequence. The general contract is that one int value is pseudorandomly generated and returned. All 2^32 possible int values are produced with (approximately) equal probability. The method is implemented by class Random.

Syntax

int random_int();
int random_int(long randomSeed);
int random_int(int minValue, int maxValue);
int random_int(int minValue, int maxValue, long randomSeed);

Attributes

  • minValue - int - start value (including)
  • maxValue - int - end value (including)
  • randomSeed - long - optional - it specifies a random series

Return type

Exception

  • TransformLangExecutorRuntimeException

Example

  print_err('Random integer: '+random_int()) prints out: Random integer: 456486773 ;


random_long

(since 2.7)

Returns a long value. Returns the pseudorandom, uniformly distributed long value from this random number generator's sequence. The general contract is that one long value is pseudorandomly generated and returned. All 2^64 possible long values are produced with (approximately) equal probability. The method is implemented by class Random.

Syntax

long random_long();
long random_long(long randomSeed);
long random_long(long minValue, long maxValue);
long random_long(long minValue, long maxValue, long randomSeed);

Attributes

  • minValue - long - start value (including)
  • maxValue - long - end value (including)
  • randomSeed - long - optional - it specifies a random series

Return type

Exception

  • TransformLangExecutorRuntimeException

Example

  print_err('Random long: '+random_long()) prints out: Random long: 4564867735646 ;


round

Returns the closest long to the argument.

Syntax

long round(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : round - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  round(10.45) returns 10
  round(10.5) returns 11
  round(10.55) returns 11


sqrt

Returns square root of “arg” or NaN if “arg” is less then zero.

Syntax

number sqrt(numeric arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line … column … : sqrt - wrong type of literal(s) – if argument is not of the one of numeric types or has null value)

Example

  sqrt(9) returns 3


String functions

char_at

Returns character of the input string at requested index.

Syntax

string char_at(string original, numeric index);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : trim – wrong type of literal – if any of the argument is not of type string)
  • TransformLangExecutorRuntimeException: Interpreter runtime exception on line 49 column 42 : CHAR_AT - NULL value not allowed - if argument is null

Example

  char_at(' text string ',1) returns 't'


chop

(since 2.7)

Chops up the string from the new line separators or from given string.

Syntax

string chop(string arg);
string chop(string arg, string toChop);

Attributes

Return type

Example

  chop("hello\\n") returns "hello";
  chop("hello world",'world') returns "hello ";


concat

Returns a string which is concatenation of function’s arguments. If argument is not of the string type, it is taken for concatenation its string representation. Usage of concat() function has the same result as addition, but works faster.

Syntax

string concat(type arg1, type arg2, …);

Attributes

  • at least two arguments of any type, each argument can be of different type

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception: concat – wrong type of literal – if argument has null value)

Example

  concat(arg1,arg2, .....);


count_char

Returns the number of occurrences of the “char” argument in “arg”, which is of the string type.

Syntax

int count_char(string arg, string char);

Attributes

Return type

Example

  count_char('somestringasanexample','e') returns 3;


cut

Returns the list of substrings that are get from the “arg” (which is of the string type) using the list of numbers specified as the second argument. The number of elements of this “listofnumbers” must be even. Each pair of adjacent numbers is used as a pair of position and length in a similar way as in the “substring(…)” function. Only the integer parts of numbers are used as position and length.

Syntax

list cut(string arg, list listofnumbers);

Attributes

Return type

Example

  cut('somestringasanexample','[2,2,1,4]') returns ['me','omes'];


edit_distance

Calculates the edit distance between two strings: number of letters, that must be changed to get from one string to another.

since 2.7 vesion.

Syntax

int edit_distance(string str1, string str2, int strength, string locale, int maxDifference);

int edit_distance(string str1, string str2, int strength, int maxDifference);

int edit_distance(string str1, string str2, int strength, string locale);

int edit_distance(string str1, string str2, string locale, int maxDifference);

int edit_distance(string str1, string str2, int strength);

int edit_distance(string str1, string str2, string locale);

int edit_distance(string str1, string str2);

Attributes

  • str1 – string - one of the strings for comparison
  • str2 – string - second of the strings for comparison
  • strength – int - strength of comparison:
    • 4 = IDENTICAL - all letters have to be identical
    • 3 = TERTIARY - lower/upper case is the same letter
    • 2 = SECONDARY - diacritic letters are equal to letters without diacritic (locale dependent) (implemented for CA, CZ, ES, DA, DE, ET, FI, FR, HR, HU, IS, IT, LT, LV, NL, NO, PL, PT, RO, SK, SL, SQ, SV, and TR in the time being)
    • 1 = PRIMARY - letters with specific symbols are equal to base letter (Collator.PRIMARY,new Locale(“en”,”UK”)
  • locale - string - locale for comparison (see above)
  • maxDifference – int - the maximum amoun of letters to be changed. After equating distance to this value, function execution is terminated and (maxDifference + 1) is returned. 3 is set as default

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : edit_distance - wrong type of literal – if arguments are not of proper types or have null values)

Example

 edit_distance('agata','agatą') returns 1
 edit_distance('agata','agatą', 2, 'PL') returns 0


find

Returns the list of substrings corresponding to occurrences of the “regex” argument in “arg”, which is of the string type.

Syntax

list find(string arg, string regex);

Attributes

Return type

Example

  find('somestringasanexample','[ea]') returns ['e','a','a','e','a','e'];


get_alphanumeric_chars

Removescharacters which are not letters nor digits from input string.

Syntax

string get_alphanumeric_chars(string original);
string get_alphanumeric_chars(string original, boolean takeAlpha, boolean takeNumeric);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : get_alphanumeric_chars - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)

Example

  get_alphanumeric_chars(' a\t1b\nc\rd \b  e \f2f\r\n') returns 'a1bcde2f'
  get_alphanumeric_chars(' a\t1b\nc\rd \b  e \f2f\r\n',true,false) returns 'abcdef'
  get_alphanumeric_chars(' a\t1b\nc\rd \b  e \f2f\r\n',false,true) returns '12'


index_of

Returns the index within input string of the first occurrence of the specified substring, starting at the specified index, or -1 if the substring does not occur

Syntax

int index_of(string str, string search);
int index_of(string str, string search, int fromIndex);

Attributes

  • str – string input string
  • search – string substring for which to search
  • fromIndex – int index from which to start the search

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : index_of - wrong type of literal(s) – if first or second argument is not of type string or third argument is not of type int
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  index_of('hello world','l') returns 2
  index_of('hello world','l',5) returns 9
  index_of('hello world','hello',1) returns -1
  index_of('hello world','world',1) returns 6


is_ascii

Tells whether or not the input string can be encoded by “US-ASCII encoder.

Syntax

boolean is_ascii(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : is_ascii - wrong type of literal(s) – if argument is not of type string
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  is_ascii('test') returns 'true'
  is_ascii('aęř') returns 'false'


is_blank

Checks if given string has characters others then space characters (SPACE_SEPARATOR, LINE_SEPARATOR, PARAGRAPH_SEPARATOR ).

Syntax

boolean is_blank(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if argument is not of type string

Example

  string test='test'; isBlank=is_blank(test) returns 'false'
  test=null; boolean isBlank2=is_blank(test) returns 'true'


is_date

Checks if the string can be parsed into a date with specified pattern (format).

Syntax

boolean is_date(string original,string format);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if arguments are not of type string
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  is_date('20Jul2000','ddMMMyyyy') returns 'true'
  is_date('4:42','HH:mm') returns 'true'
  is_date('20.11.2007','dd-MM-yyyy') returns 'false'
  is_date('test 20.11.2007','hhmm dd.MM.yyyy') returns 'false'

From ver. 2.4:

Checks if given string can be parsed to date due to given pattern and locale. With lenient argument set to true, convertor may use heuristics to interpret inputs that do not precisely match this object's format. With strict converting, inputs must match this object's format. First two arguments are necessary; when there are only three arguments, third argument is treated as locale if it is of type string (lenient is set to false by default) or as lenient if it is of type bool (locale is set to system value by default).

Checks if the string can be parsed into a date with specified pattern (format). Allows changing parser strictness (lenient):

Syntax

boolean is_date(string original,string format,bool lenient);

Attributes

Checks if the string can be parsed into a date with specified pattern (format) and locale:

Syntax

boolean is_date(string original,string format,string locale);

Attributes

Checks if the string can be parsed into a date with specified pattern (format) and locale. Allows changing parser strictness (lenient):

Syntax

boolean is_date(string original,string format,string locale,bool lenient);

Attributes

Example

  is_date('20Jul2000','ddMMMyyyy','en.GB') returns 'true'
  iis_date('20Jul2000','ddMMMyyyy','pl.PL') returns 'false'
  is_date('20-15-2007','dd-MM-yyyy') returns 'true'
 
  is_date('20-15-2007','dd-MM-yyyy',false) returns 'false'
  is_date('20-15-2007','dd-MM-yyyy',true) returns 'true'


is_integer

Checks if given string can be parsed as integer number with radix 10.

Syntax

boolean is_integer(string str);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  is_integer('h3') returns false
  is_integer('78642325688990076654322234') returns false
  is_integer('786423') returns true


is_long

Checks if given string can be parsed as long number with radix 10.

Syntax

boolean is_long(string str);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  is_integer('h3') returns false
  is_integer('78642325688990076654322234') returns false
  is_integer('786423') returns true


is_number

Checks if given string can be parsed as double number with 10 radix.

Syntax

boolean is_number(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : is_number - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  is_number('1g')) returns 'false'
  is_number('8982.8992e-2') returns 'true'


join

Joins parameters to one string delimited by first argument. When there is list or map variable among parameters, each element of this variable is delimited by delimiter.

Syntax

string join(string delimiter,any parameter, …);

Attributes

Return type

Exception

Example

  list seznam = [16, 17, 18, 19]
  map mapa = {f2=hello, f1=99}
  list novy=[{f2=hello, f1=99}, {f2=xxx, f1=10}, {f2=hello, f1=99}]
  join(':del:',seznam,mapa,novy[1]) returns '16:del:17:del:18:del:19:del:f2=hello:del:f1=99:del:f2=xxx:del:f1=10:del:'


left

Returns length first characters from original string.

Syntax

string left(string original,numeric length);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)
  • StringIndexOutOfBoundsException (String index out of range: 14 – if “length” is out of string bounds or “length” is less then 0)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  left('text', 2) returns 'te'


length

Returns the length of “arg” string or number of elements in list or map containers.

Syntax

int length(type arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : length – wrong type of literal – if argument is not of type string or list or map or has null value)

Example

  length('value') returns 5;


lowercase

Returns lower case representation of original string.

Syntax

string lowercase(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : lowercase – wrong type of literal – if argument is not of type string or has null value)

Example

  lowercase('Value') returns 'value';


metaphone

Finds the metaphone value of a String (see A Better Phonetic Lookup for more info).

since 2.7 version

Syntax

string metaphone(string original, int maxLength);

Attributes

  • original – string String to find the metaphone code for
  • maxLength – int Maximal length of output string. 4 is set as default.

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : metaphone - wrong type of literal – if arguments are not of proper types or have null value)

Example

  metaphone('CHRISSIE') returns XRS
  metaphone("Gwendoline", 10) returns KWNTLN
  metaphone("Gwendoline") returns KWNT


NYSIIS

Finds The New York State Identification and Intelligence System Phonetic Code (see New York State Identification and Intelligence System for more info).

since 2.7 version

Syntax

string NYSIIS(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : NYSIIS - wrong type of literal – if argument is not of type string or has null value)

Example

  NYSIIS("Cope") retuns 'CAP'
  NYSIIS("Kipp") returns 'CAP'


random_string

(since 2.7)

Returns strings generated at random, consisting of lowercase letters (a-z). The length of each string can even be equal to that specified by the arguments. However, the strings cannot be shorter or longer.

Syntax

string random_string(int minimum length of string,int maximum length of string);
string random_string(int minimum length of string,int maximum length of string, long randomSeed);

Attributes

  • minimum length of string – int - minimum length (inclusive)
  • maximum length of string – int - maximum length (inclusive)
  • randomSeed – long - optional - it specifies a random series

Return type

Exception

Example

  random_string(3, 5) can return 'dfg' for one record field, 'rtps' for another, etc. 
  It can also return 'peqoh', however it can neither return 'zh' nor 'eldoft'.


remove_blank_space

Removes blank spaces from a string.

Syntax

string remove_blank_space(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : remove_diacritic - wrong type of literal(s) – if argument is not of type string

Example

  remove_blank_space(' a\tb\nc\rd   e \ff\r\n') returns 'abcdef'


remove_diacritic

Replaces diacritic chars by theirs equivalence without diacritical marks. It works only for chars for which decomposition is defined.

Syntax

string remove_diacritic(string);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : remove_diacritic - wrong type of literal(s) – if argument is not of type string

Example

  remove_diacritic('teścik') returns 'tescik'


remove_nonascii

Removes non-ascii characters from a string.

Syntax

string remove_nonascii(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : remove_diacritic - wrong type of literal(s) – if argument is not of type string

Example

  remove_nonascii('teścik') returns 'tecik'


remove_nonprintable

Removes non-printable characters from a string.

Syntax

string remove_nonascii(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : remove_diacritic - wrong type of literal(s) – if argument is not of type string

Example

  remove_nonprintable('kula?ou?k?jabl??ko') returns 'kulaoukjablko'


replace

returns string which has all occurrences of “regex” pattern changed to “replacement”.

Syntax

string replace(string original, string regex, string replacement);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception: NULL value not allowed – if argument has null value)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception : replace - wrong type of literal(s) – if argument is not of the type string)

Example

  replace('HELlo','[lL]','t') returns 'Hetto' – changed every 'l' or 'L' to 't'


right

Returns length last characters from original string.

Syntax

string right(string original,numeric length);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if first argument is not of type string or second argument is not of one of numeric types)
  • StringIndexOutOfBoundsException (String index out of range: 14 – if “length” is out of string bounds or “length” is less then 0)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  right('text', 2) returns 'xt'


soundex

Returns a string code for an input string consists of a letter followed by three numbers: the letter is the first letter of the argument, and the numbers encode the remaining consonants. Similar sounding consonants share the same number.

Syntax

string soundex(string arg);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception: concat – wrong type of literal – if argument has null value or is not of string type)

Example

  soundex('word'); returns W600


split

Splits this string around matches of the given regular expression.

Syntax

list split(string original, string regex);

Attributes

  • original – string
  • regex – string - regular expression used as splitter

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 1 column 99 : Java exception [java.lang.RuntimeException] occured during external function call ! - 'not a STRING value' : – if argument is not of type string or has null value)

Example

  split('somestring','[st]') returns [,ome,,ring]


substring

Returns sub-string of the original string starting from “from” letter and of length of “length”. When “from” or “length” are of number or decimal type it is taken integer part of argument.

Syntax

string substring(string original, numeric from, numeric length);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : substring - wrong type of literal(s) – if first argument is not of type string or second or third argument is not of one of numeric types)
  • StringIndexOutOfBoundsException (String index out of range: 14 – if “from” or “from+length” is out of string bounds or “length” is less then 0)
  • TransformLangExecutorRuntimeException (Interpreter runtime exception on line 3 column 32 : NULL value not allowed – if an argument has null value)

Example

  substring('text', 1, 2) returns 'ex'


translate

Translates single characters in a string to different characters: replaces single characters at a time, translating the nth character in the match set with the nth character in the replacement set

Syntax

string translate(string original,string searchingSet, string replaceSet);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : translate - wrong type of literal(s) – if argument is not of type string

Example

  translate('hello','leo','pii') returns 'hippi'


trim

Returns a copy of the string, with leading and trailing white spaces omitted.

Syntax

string trim(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : trim – wrong type of literal – if argument is not of type string or has null value)

Example

  trim(' text string ') returns 'text string'


uppercase

Returns upper case representation of original string.

Syntax

string uppercase(string original);

Attributes

Return type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : uppercase - wrong type of literal – if argument is not of type string or has null value)

Example

  uppercase('Text') returns 'TEXT'


Container (List/Map) functions

copy

Adds the list specified as the second argument to the end of the list specified as the first argument and returns the resulting list.

Syntax

list copy(list arg1, list arg2);

Attributes

Return type

Example

  list la;
  list lb;
  la=[2,4,3];
  lb=[1,5];
  copy(la,lb) returns [2,4,3,1,5]


insert

Takes the elements contained as the arguments starting from the third argument and inserts them to the list specified as the first argument. The new elements are inserted to the list starting from the position specified as the second argument.

Syntax

boolean insert(list arg, numeric position, type newelement1, …, type newelementN);

Attributes

Return type

Example

  list la;
  la=[3.5,4.1,1.7];
  insert(la,2,6.4, 3.2) returns a boolean value. la is [3.5,4.1,6.4,3.2,1.7] now.


poll

Removes the first element from the list and returns it.

Syntax

type poll(list arg);

Attributes

Return type

Example

  list la;
  la=[2,8,16];
  poll(la) returns 2;


pop

Removes the last element from the list and returns it.

Syntax

type pop(list arg);

Attributes

Return type

Example

  list la;
  la=[2,8,16];
  pop(la) returns 16;


push

Adds a new element to the end of the list and returns the resulting list.

Syntax

boolean push(list arg, type newelement);

Attributes

Return type

Example

  list la;
  la=[2,4,5];
  push(la,1) returns a boolean value. la is [2,4,5,1] now.


remove

Removes the element of the list at the specified position and returns the resulting list.

Syntax

list remove(list arg, numeric position);

Attributes

Return type

Example

  list la;
  la=[3,16,27,5];
  remove(la,2) returns [3,16,5];


remove_all

Empties the list. Returns a boolean value.

Syntax

boolean remove_all(list arg);

Attributes

Return type

Example

 


reverse

Reverses the order of the elements of the list and returns the resulting list.

Syntax

list reverse(list arg);

Attributes

Return type

Example

  list la;
  la=[3,5,2,16,4,1,9];
  reverse(la) returns [9,1,4,16,2,5,3]


sort

Sorts the elements of the list in ascending order and returns the resulting list.

Syntax

list sort(list arg);

Attributes

Return type

Example

  list la;
  la=[3,5,2,16,4,1,9];
  sort(la) returns [1,2,3,4,5,9,16]


trunc

Returns truncation of “arg” - in case of list or map parameter, the effect is emptying the list or map passed in and the return value is null.

Syntax

trunc(list arg);
trunc(map arg);

Attributes

dict_get_str

Returns string representation of dictionary object under specified name/key.

Syntax

string dict_get_str(string key);

Attributes

Return type

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 8 column 9 : dict_get_str- wrong type of literal(s)– if “key” is not of type string or has null value

Example

dict_get_str('my_key') - returns value stored in dictionary under the key 'my_key' 


dict_put_str

Stores value passed as 2nd parameter under key (1st parameter) into graph dictionary.

Syntax

boolean dict_put_str(string key, string value);

Attributes

Return type

  • boolean - true if storing was successful, false in other case

Exception

  • org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 8 column 9 : dict_get_str- wrong type of literal(s)– if any of the parameters is not of type string or has null value

Example

dict_put_str('my_key','my_value'); - puts into dictionary value 'my_value' associated with key 'my_key'


Miscellaneous functions

breakpoint

Prints out global and local variables.

Syntax

void breakpoint();

Attributes

Return type

Exception

Example

  breakpoint();


iif

Returns “true_val” if “con” is true or “false_val” in other case.

Syntax

type iif(boolean con, type true_val, type false_val);

Attributes

  • con – boolean
  • true_val – type - any type
  • false_val – type - the same as true_val

Return type

  • type - the same as the true_val and false_val type

Exception

  • TransformLangExecutorRuntimeException (Interpreter runtime exception : iif - wrong type of conditional – if first argument is not of the boolean type)

Example

  iif(true, 'val1', 'val2') returns 'val1'
  iif(false, 'val1', 'val2') returns 'val2'


isnull

Returns true if and only if “arg” value is null.

Syntax

boolean isnull(type arg);

Attributes

Return type

Exception

Example

  string s;
  isnull(s) returns true;
  s = 'value';
  isnull(s) returns false;


nvl

Returns value of “arg” if it is not null or “default” value if “arg” value is null.

Syntax

type nvl(type arg, type default);

Attributes

  • arg – type - any type
  • default - type - the same as the arg type

Return type

  • type - the same as the arg type

Exception

Example

  string s;
  nvl(s, 'value') returns 'value'
  nvl('dest', 'value') returns 'dest'


nvl2

Returns value of “true_value” if “arg” value is not null, or “false_value” value if “arg” value is null.

Syntax

type nvl2(type arg, type true_value, type false_value);

Attributes

  • arg – type - any type
  • true_value - type - the same as the arg type
  • false_value - type - the same as the arg type

Return type

  • type - the same as the arg type

Exception

Example

  nvl2('something', 'is not null', 'is null') returns 'is not null'
  nvl2(null, 'is not null', 'is null') returns 'is null'


print_err

Prints out on error output “message” with location of error message.

Syntax

void print_err(type message);
void print_err(type message, boolean printLocation);

Attributes

Return type

Exception

Example

  print_err('some error message text');


print_log

Sends message to logger. Remember that log levels must be specified as constants in the function! They can neither be received as field values nor be defined as variables.

Syntax

void print_log(enum level, type message);

Attributes

  • level - one of: debug, info, warn, error, fatal.
  • message – type

Return type

Exception

  • TransformLangExecutorRuntimeException: Interpreter runtime exception on line 1 column 37 : Can NOT perform logging operation - no logger defined

Example

  print_log(fatal,'some error message text');


print_stack

Prints out all variables from stack.

Syntax

void print_stack();

Attributes

Return type

Exception

Example

  print_stack();


raise_error

Throws out error.

Syntax

void raise_error(string message);

Attributes

Return type

Exception

  • TokenMgrError: Lexical error at line 1, column 62. Encountered: <EOF> after : ”” - if raise_error is last instruction

Example

  raise_error(\"my testing error\"); throws 
org.jetel.interpreter.TransformLangExecutorRuntimeException: Interpreter runtime exception on line 1 column 13 : 
!!! Exception raised by user: my testing error


transf_lang_functions.txt · Last modified: 2010/05/14 12:25 by twaller
Back to top
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0