JavaInvoke_

Syntax

JavaInvoke_(ClassName: String, MethodName: String, MethodSig: String, Params: Array)

Parameters

ClassName. Java class name in file system or system unit name in the JNI signature. When indicating Java class in file system, file with the *.class extension is used. Parameter value is case-sensitive.

MethodName. The executed method name. Parameter value is case-sensitive.

MethodSig. JNI signature of the method.

Params. Parameters sent to method. Values of method parameters can be sent as a separate array or enumerated via a comma. If the executed method does not contain input parameters, do not specify Params.

Description

The JavaInvoke_ method executes static Java method and returns the result of its work.

Comments

To execute the method, the file with the *.class extension must be located at the path which is set using the Options string parameter in the registry key HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Java. For details see the Connecting External Modules to Foresight Analytics Platform section.

Example

Consider the Java code:

public class math {

    public static double staticFunc(double a, double b){

        return (a + b)/2;

    }

}

The table contains examples of formulas using the JavaInvoke_ method:

Formula Result Description
=JavaInvoke_("math", "staticFunc", "(DD)D", 4.0, 2.0) 3.0 The arithmetic staticFunc function is executed in the class named math. Parameters of real types are specified in the function - the a variable is set to 4.0, the b variable is set to 2.0. The method returns arithmetic function calculation result.
=JavaInvoke_("math", "staticFunc", "(DD)D",  C3, C4) 5.0 The staticFunc arithmetic function is executed in the class named math. Parameters of real types are specified in the function - the a variable is set to the value specified in the C3 cell, the b variable is set to the value specified in the C4 cell. Value contained in the C3 cell is 4.0, in the C4 cell - 6.0. The method returns arithmetic function calculation result.

See also:

Functions Available in Expression Editor | Working with Java | Java.Invoke