Class SEScriptEngineFactory

  • All Implemented Interfaces:
    javax.script.ScriptEngineFactory

    public final class SEScriptEngineFactory
    extends ScriptEngineFactoryBase
    A script engine factory that provides access to the Strange Rhino scripting engine via the JSR 223 scripting API. This is a lower-level API than using ScriptMonkey, but a higher-level API than using Strange Rhino directly.
    Author:
    Chris Jennings
    • Constructor Detail

      • SEScriptEngineFactory

        public SEScriptEngineFactory()
        Creates a script engine factory for Strange Eons scripts.
    • Method Detail

      • getDefaultScriptEngine

        public static SEScriptEngine getDefaultScriptEngine()
        Returns a standard script engine using the shared script engine factory.
        Returns:
        a new script engine
        See Also:
        getDefaultFactory()
      • makeCurrentThreadAUtilityThread

        public static void makeCurrentThreadAUtilityThread()
        Makes the current thread a "utility thread". A utility thread is a separate thread used to run an extensive JavaScript-based tool. Calling this alters the behaviour of all script engines created in the thread. For example, engines in the thread will ignore warnings regardless of the global warning preference.
      • isStandardThread

        public static boolean isStandardThread()
        Returns whether the current thread is a standard thread or a utility thread.
        Returns:
        true if the current thread is a standard thread
      • getVersion

        public static java.lang.String getVersion()
        Returns a short string that describes the version of script engines produced by this factory.
        Returns:
        the engine version string
      • getWarningsEnabled

        public static boolean getWarningsEnabled()
        Returns true the scripting system will report warnings in addition to errors.
        Returns:
        true if warnings are reported
        See Also:
        setWarningsEnabled(boolean)
      • setWarningsEnabled

        public static void setWarningsEnabled​(boolean warningsEnabled)
        Sets whether the scripting system will report warnings in addition to errors.
        Parameters:
        warningsEnabled - true if warnings are reported
        See Also:
        getWarningsEnabled()
      • getWarningsAreTreatedAsErrors

        public static boolean getWarningsAreTreatedAsErrors()
        Sets whether warnings will be promoted to errors.
        Returns:
        if true, compilation warnings will prevent scripts from running
      • setWarningsAreTreatedAsErrors

        public static void setWarningsAreTreatedAsErrors​(boolean treatAsErrors)
        Gets whether warnings will be promoted to errors.
        Parameters:
        treatAsErrors - if true, compilation warnings will prevent scripts from running
      • getOptimizationLevel

        public static int getOptimizationLevel()
        Returns the optimization level that will be applied to scripts.
        Returns:
        the current optimization level
        See Also:
        setOptimizationLevel(int)
      • setOptimizationLevel

        public static void setOptimizationLevel​(int optimizationLevel)
        Sets the optimization level that will be applied to scripts. Valid values include -1 (interpret only, no compilation), 0 (compile without optimization), or 1 through 9 (enable successive degrees of optimization; in practice not all levels may have distinct effects).
        Parameters:
        optimizationLevel - the new optimization level
        Throws:
        java.lang.IllegalArgumentException - if the new level is outside of the legal range
        See Also:
        getOptimizationLevel()
      • isDebugInfoEnabled

        public static boolean isDebugInfoEnabled()
        Returns whether debugging information will be generated for parsed scripts.
        Returns:
        true if generation of debugging info is enabled
      • setDebugInfoEnabled

        public static void setDebugInfoEnabled​(boolean debugInfoEnabled)
        Sets whether debugging information will be generated for parsed scripts. If this is enabled, it may limit the optimization level that is effectively applied to executed scripts.
        Parameters:
        debugInfoEnabled - true to enable generation of debugging info
      • getNames

        public java.util.List<java.lang.String> getNames()
      • getExtensions

        public java.util.List<java.lang.String> getExtensions()
      • getMimeTypes

        public java.util.List<java.lang.String> getMimeTypes()
      • getParameter

        public java.lang.Object getParameter​(java.lang.String key)
      • getMethodCallSyntax

        public java.lang.String getMethodCallSyntax​(java.lang.String obj,
                                                    java.lang.String method,
                                                    java.lang.String... args)
      • getOutputStatement

        public java.lang.String getOutputStatement​(java.lang.String toDisplay)
      • getProgram

        public java.lang.String getProgram​(java.lang.String... statements)