java:call
Calls a static or non-static method of a Java class or object in data shaping expressions.
Arguments
For static method calls:
- Class name (string).
- Method name (string).
- Arguments of the method (any type).
For non-static method calls:
- Java object instance created with java:new.
- Method name (string).
- Arguments of the method (any type).
Examples
Calling a static method:
java:call("java.lang.Double", "compare", 3.1415d, 1.51d)This example compares two double values using Java Double.compare() method.
Calling a non-static method:
java:call(java:new("java.util.Random", 536815L), "nextInt", 100)This example creates a Random object with a seed and calls its nextInt method.
Chaining Java calls:
java:call(java:call("java.lang.String", "valueOf", 100), "concat", "$")This example converts the integer 100 to a string, then concatenates a dollar sign.
java:call(java:call(java:new("java.text.SimpleDateFormat", "yyyy-MM-dd"), "parse", "2018-10-15"), "getDate")This example creates a SimpleDateFormat object, parses a date string, and retrieves the date.