Class PolyglotUtil

java.lang.Object
com.iamsoft.util.ui.javafx.script.PolyglotUtil

public final class PolyglotUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Map<String,Language>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Callable<T>
    createTask(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
    Evaluates the specified code using the specified context and executor and waits for result without blocking the UI.
    static <T> void
    eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, BiConsumer<T,Exception> pResultConsumer, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
     
    static <T> T
    eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
    Evaluates the specified code using the specified context and executor and waits for result without blocking the UI.
    static <T> T
    eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, org.graalvm.polyglot.Context pContext, Consumer<Runnable> pExecutor, long pTimeoutMs)
    Evaluates the specified code using the specified context executor and waits for result without blocking the UI.
    static <T> T
    eval(String pSource, String pLanguageId, Map<String,Object> pVarMap, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
    Evaluates the specified code using the specified context and executor and waits for result without blocking the UI.
    static <T> T
    jsEval(String pSource, Function<org.graalvm.polyglot.Value,T> pResultMapper, long pTimeoutMs)
    Evaluates the specified JavaScript code on a background thread and waits for result without blocking the UI.
    static <T> T
    jsEval(String pSource, Function<org.graalvm.polyglot.Value,T> pResultMapper, Consumer<Runnable> pExecutor, long pTimeoutMs)
    Evaluates the specified JavaScript code using the specified executor and waits for result without blocking the UI.
    static String
    jsEvalString(String pSource, long pTimeoutMs)
    Evaluates the specified JavaScript code on a background thread and waits for result without blocking the UI.
    static String
    jsEvalString(String pSource, Consumer<Runnable> pExecutor, long pTimeoutMs)
    Evaluates the specified JavaScript code using the specified executor and waits for result without blocking the UI.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • jsEval

      public static <T> T jsEval(String pSource, Function<org.graalvm.polyglot.Value,T> pResultMapper, long pTimeoutMs) throws InterruptedException
      Evaluates the specified JavaScript code on a background thread and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • jsEval

      public static <T> T jsEval(String pSource, Function<org.graalvm.polyglot.Value,T> pResultMapper, Consumer<Runnable> pExecutor, long pTimeoutMs) throws InterruptedException
      Evaluates the specified JavaScript code using the specified executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • eval

      public static <T> T eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, org.graalvm.polyglot.Context pContext, Consumer<Runnable> pExecutor, long pTimeoutMs) throws InterruptedException
      Evaluates the specified code using the specified context executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • eval

      public static <T> T eval(String pSource, String pLanguageId, Map<String,Object> pVarMap, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pOnContextClosing) throws InterruptedException
      Evaluates the specified code using the specified context and executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • eval

      public static <T> void eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, BiConsumer<T,Exception> pResultConsumer, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
    • eval

      public static <T> T eval(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, Consumer<Runnable> pExecutor, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing) throws InterruptedException
      Evaluates the specified code using the specified context and executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • createTask

      public static <T> Callable<T> createTask(String pSource, String pLanguageId, Function<org.graalvm.polyglot.Value,T> pResultMapper, Supplier<org.graalvm.polyglot.Context> pContextSupplier, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval, Consumer<org.graalvm.polyglot.Context> pOnContextClosing)
      Evaluates the specified code using the specified context and executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • jsEvalString

      public static String jsEvalString(String pSource, long pTimeoutMs) throws InterruptedException
      Evaluates the specified JavaScript code on a background thread and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached
    • jsEvalString

      public static String jsEvalString(String pSource, Consumer<Runnable> pExecutor, long pTimeoutMs) throws InterruptedException
      Evaluates the specified JavaScript code using the specified executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.
      Throws:
      InterruptedException - if the specified timeout is reached