Apama Documentation : Developing Apama Applications : EPL Reference : Types : Type conversion
Type conversion
EPL requires strict type conformance in expressions, assignment and other statements, parameters in action and method calls, and most other constructs. This means that
*The left and right operands of most binary operators must be of the same type.
*An actual parameter passed in a method or action invocation must be of the same type as the type of the corresponding formal parameter in the action or method definition.
*The expression result type on the right side of an assignment statement must be the same type as that of the target variable.
*The expression result type in a variable initializer must be the same type as that of the variable.
*The expression result type in a subscript expression must be integer.
*The expression result type in a return statement must be the same type as that specified in the action's returns clause.
EPL does not allow implicit or explicit casting to perform type conversions. Instead, the inbuilt methods associated with each type include a set of methods which perform type conversion. For example:
string number;
integer value;

number := "10";
value := number.toInteger();
This illustrates how to map a string to an integer. The string must start with some numeric characters, and only these are considered. So if the string's value was “10h”, the integer value obtained from it would have been 10. Had the conversion not been possible because the string did not start with a valid numeric value, then value would have been set to 0.
These method calls can also be made inside event expressions as long as the type of the value returned is of the same type as the parameter where it is used. Therefore one can write:
on all StockTick("ACME", number.toFloat());
Method calls can be chained. For example one can write:
print ((2 + 3).toString().toFloat() + 4.0).toString();
Note that as shown in this example, method calls can also be made on literals.
The following table indicates the source and target type-pairs for which type conversion methods are provided.
In the table above, "assign" means values of the type can be directly assigned to another variable of the same type, without calling a type conversion method and "clone" means a value of the type can be copied by calling the clone() method.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback