Class JavaInteroperabilityUtils


  • public final class JavaInteroperabilityUtils
    extends java.lang.Object
    Collection of utilities that ease the interoperability with Java.
    • Field Detail

      • METADATA

        public static final Metadata METADATA
        A fake Metadata object to be used when no data or original source code is available.
    • Method Detail

      • runStaticMethodWithProtelisArguments

        public static java.lang.Object runStaticMethodWithProtelisArguments​(ExecutionContext context,
                                                                            java.lang.reflect.Method method,
                                                                            ProtelisAST<?>... arguments)
        Executes a static Java method using Protelis-produced arguments.
        Parameters:
        context - ExecutionContext
        method - a valid Method name
        arguments - the arguments for the method
        Returns:
        the result of the evaluation
      • runMethodWithProtelisArguments

        public static java.lang.Object runMethodWithProtelisArguments​(ExecutionContext context,
                                                                      ProtelisAST<?> receiver,
                                                                      java.lang.String method,
                                                                      ProtelisAST<?>... arguments)
        Executes a Java method on a reiceiver Java object computed by Protelis using Protelis-produced arguments.
        Parameters:
        context - ExecutionContext
        receiver - the ProtelisAST on which annotation the method will be invoked
        method - a valid Method name
        arguments - the arguments for the method
        Returns:
        the result of the evaluation
      • runProtelisFunctionWithJavaArguments

        public static java.lang.Object runProtelisFunctionWithJavaArguments​(ExecutionContext context,
                                                                            ProtelisAST<FunctionDefinition> function,
                                                                            java.lang.Object... arguments)
        Runs a Protelis function from Java using Java-produced arguments, provided a context.
        Parameters:
        context - ExecutionContext
        function - an ProtelisAST with the FunctionDefinition to instance and use
        arguments - the function arguments
        Returns:
        the result of the evaluation
      • runProtelisFunctionWithJavaArguments

        @Nonnull
        public static java.lang.Object runProtelisFunctionWithJavaArguments​(@Nonnull
                                                                            ExecutionContext context,
                                                                            @Nonnull
                                                                            FunctionDefinition function,
                                                                            @Nonnull
                                                                            java.util.List<?> arguments)
        Runs a Protelis function from Java using Java-produced arguments, provided a context.
        Parameters:
        context - ExecutionContext
        function - the FunctionDefinition to instance and use
        arguments - the function arguments
        Returns:
        the result of the evaluation