This documentation is for WSO2 CEP 4.1.0. View the home page of the latest release.

||
Skip to end of metadata
Go to start of metadata

Following are the supported inbuilt functions of Siddhi

coalesce

Syntax<int|long|float|double|string|bool|object> coalesce(<int|long|float|double|string|bool|object> arg1<int|long|float|double|string|bool|object> arg2,.., <int|long|float|double|string|bool|object> argN)
Extension TypeFunction
DescriptionReturns the value of the first input parameter that is not null.
ParametersThis function accepts one or more parameters. They can belong to any one of the available types. All the specified parameters should be of the same type.
Return TypeThis will be the same as the type of the first input parameter.
Examples
  • coalesce('123', null, '789') returns 123
  • coalesce(null, 76, 567) returns 76
  • coalesce(null, null, null) returns null

 

convert

Syntax<int|long|float|double|string|bool> convert(<int|long|float|double|string|bool> toBeConverted<string> convertedTo)
Extension TypeFunction
DescriptionConverts the first input parameter according to the convertedTo parameter. 
Parameters
  • toBeConverted: This specifies the value to be converted. The type of this value can be any of the available types other than object.
  • convertedTo: A string constant parameter expressing the conveverted to type using one of the following strings values: int, long, float, double, string, bool.
Return TypeThe return type is the same as the type specified by the convertedTo parameter.
Examples
  • convert('123', 'double') returns 123.0
  • convert(45.9, 'int') returns 46
  • convert(true, 'string') returns true

 

instanceOfBoolean

Syntax<bool> instanceOfBoolean(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of Boolean or not.
Parameters
  • arg: The parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of Boolean, or false if the parameter is not an instance of Boolean.
Examples
  • instanceOfBoolean(123) returns false
  • instanceOfBoolean(true) returns true
  • instanceOfBoolean(false) returns true

instanceOfDouble

Syntax<bool> instanceOfDouble(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of Double or not.
Parameters
  • arg: The parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of Double, or false if the parameter is not an instance of Double.
Examples
  • instanceOfDouble(123) returns false
  • instanceOfDouble(56.45) returns true
  • instanceOfDouble(false) returns false

instanceOfFloat

Syntax<bool> instanceOfFloat(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of Float or not.
ParameterThe parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of Float, or false if the parameter is not an instance of Float.
Examples
  • instanceOfFloat(123) returns false
  • instanceOfFloat(56.45) returns false
  • instanceOfFloat(56.45f) returns true

instanceOfInteger

Syntax<bool> instanceOfInteger(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of Integer or not.
ParameterThe parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of Integer, or false if the parameter is not an instance of Integer.
Examples
  • instanceOfInteger(123) returns true
  • instanceOfInteger(56.45) returns false
  • instanceOfInteger(56.45f) returns false

instanceOfLong

Syntax<bool> instanceOfLong(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of Long or not.
ParameterThe parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of Long, or false if the parameter is not an instance of Long.
Examples
  • instanceOfLong(123) returns false
  • instanceOfLong(5667l) returns true
  • instanceOfLong(56.67) returns false

instanceOfString

Syntax<bool> instanceOfString(<int|long|float|double|string|bool|object> arg)
Extension TypeFunction
DescriptionChecks whether the parameter is an instance of String or not.
ParameterThe parameter to be checked.
Return TypeReturns bool: true if the parameter is an instance of String, or false if the parameter is not an instance of String.
Examples
  • instanceOfString('test') returns true
  • instanceOfString('5667') returns true
  • instanceOfString(56.67) returns false

UUID

Syntax<string> UUID()
Extension TypeFunction
DescriptionGenerates a UUID (Universally Unique Identifier).
Return TypeReturns a UUID string.
Examples
  • UUID() returns a34eec40-32c2-44fe-8075-7f4fde2e2dd8
  • The following converts a room number to string, introducing a message ID to each event.

maximum

Syntax<int|long|float|double> maximum(<int|long|float|double>)
Extension TypeFunction
DescriptionReturns the maximum value of the input parameters.
ParameterThis function accepts one or more parameters. They can belong to any one of the available types. All the specified parameters should be of the same type.
Return TypeThis will be the same as the type of the first input parameter.
Examples
  • maximum(37.88, 38.12, 37.62) returns 38.12.
  • maximum(15, 30, 25, 57 )  returns 57.

minimum

Syntax<int|long|float|double> minimum(<int|long|float|double>)
Extension TypeFunction
DescriptionReturns the minimum value of the input parameters.
ParameterThis function accepts one or more parameters. They can belong to any one of the available types. All the specified parameters should be of the same type.
Return TypeThis will be the same as the type of the first input parameter.
Examples
  • minimum(37.88, 38.12, 37.62) returns 37.62.
  • minimum(15, 30, 25, 57 ) returns 15.

cast

Syntax<int|long|float|double|string|bool|object> cast(<object> toBeCasted<string> castTo)
Extension TypeFunction
Description

Converts the first parameter according to the castTo parameter. Incompatible arguments cause Class Cast exceptions if further processed. This function is used with map extension that returns attributes of the object type. You can use this function to cast the object to an accurate and concrete type.

Parameters
  • toBeCasted: This specifies the attribute to be casted.
  • castTo: A string constant parameter expressing the cast to type using one of the following strings values: int, long, float, double, string, bool.
Return TypeThis is the same as the type of the second input parameter.
Examples
  • cast(100.3, 'double') returns 100.3d
  • cast(true, 'double') returns true
  • cast(null, 'double') returns null

ifThenElse

Syntax<bool> ifThenElse(<bool> condition<int|long|float|double|string|bool|object> arg1, <int|long|float|double|string|bool|object> arg2)
Extension TypeFunction
Description

Returns the the value of the arg1 parameter if the condition parameter is set to true, or returns the value of the arg2 parameter if the condition parameter is set to false.

Parameters
  • condition: This specifies the if then else condition value. The data type for this parameter is bool
  • arg1: This specifies the value to be returned if the value of the condition parameter is true. The data type of he value specified should be int, long, float, double, string, bool, or object.
  • arg2: This specifies the value to be returned if the value of the condition parameter is false. The data type of he value specified should be int, long, float, double, string, bool, or object.
Return Type

Returns <int|long|float|double|string|bool|object>arg1 if the value of the condition parameter is true, or  <int|long|float|double|string|bool|object> arg2  if the value of the condition parameter is false.

Examples
  • ifThenElse(sensorValue > 35,'High','Low') returns High if sensorValue = 50.
  • ifThenElse(voltage < 5, 0, 1) returns 1 if voltage= 12.
  • ifThenElse(password == 'admin', true, false) returns true if password = admin.


  • No labels