Class SEScriptEngineFactory
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.engine.ScriptEngineFactoryBase
-
- ca.cgjennings.apps.arkham.plugins.engine.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 usingScriptMonkey
, but a higher-level API than using Strange Rhino directly.- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description SEScriptEngineFactory()
Creates a script engine factory for Strange Eons scripts.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SEScriptEngineFactory
getDefaultFactory()
Returns a standard shared instance of this factory.static SEScriptEngine
getDefaultScriptEngine()
Returns a standard script engine using the shared script engine factory.java.util.List<java.lang.String>
getExtensions()
java.lang.String
getMethodCallSyntax(java.lang.String obj, java.lang.String method, java.lang.String... args)
java.util.List<java.lang.String>
getMimeTypes()
java.util.List<java.lang.String>
getNames()
static int
getOptimizationLevel()
Returns the optimization level that will be applied to scripts.java.lang.String
getOutputStatement(java.lang.String toDisplay)
java.lang.Object
getParameter(java.lang.String key)
java.lang.String
getProgram(java.lang.String... statements)
SEScriptEngine
getScriptEngine()
Returns a new script engine created by this factory instance.static java.lang.String
getVersion()
Returns a short string that describes the version of script engines produced by this factory.static boolean
getWarningsAreTreatedAsErrors()
Sets whether warnings will be promoted to errors.static boolean
getWarningsEnabled()
Returnstrue
the scripting system will report warnings in addition to errors.static boolean
isDebugInfoEnabled()
Returns whether debugging information will be generated for parsed scripts.static boolean
isStandardThread()
Returns whether the current thread is a standard thread or a utility thread.static void
makeCurrentThreadAUtilityThread()
Makes the current thread a "utility thread".static void
setDebugInfoEnabled(boolean debugInfoEnabled)
Sets whether debugging information will be generated for parsed scripts.static void
setOptimizationLevel(int optimizationLevel)
Sets the optimization level that will be applied to scripts.static void
setWarningsAreTreatedAsErrors(boolean treatAsErrors)
Gets whether warnings will be promoted to errors.static void
setWarningsEnabled(boolean warningsEnabled)
Sets whether the scripting system will report warnings in addition to errors.-
Methods inherited from class ca.cgjennings.apps.arkham.plugins.engine.ScriptEngineFactoryBase
getEngineName, getEngineVersion, getLanguageName, getLanguageVersion, getName
-
-
-
-
Method Detail
-
getDefaultFactory
public static SEScriptEngineFactory getDefaultFactory()
Returns a standard shared instance of this factory.- Returns:
- the standard script engine factory
- See Also:
getDefaultScriptEngine()
-
getDefaultScriptEngine
public static SEScriptEngine getDefaultScriptEngine()
Returns a standard script engine using the shared script engine factory.- Returns:
- a new script engine
- See Also:
getDefaultFactory()
-
getScriptEngine
public SEScriptEngine getScriptEngine()
Returns a new script engine created by this factory instance.- Returns:
- a new script engine
- See Also:
getDefaultScriptEngine()
-
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()
Returnstrue
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)
-
-