@ThreadRestricted public final class JavaScriptIncluder extends Object
vo
), with which to load modules. For example:
vo.inc( 'ABS-OR-REL-PATH/module.jsm' );
Script files must be encoded in UTF-8, or equivalently ASCII.
Constructor and Description |
---|
JavaScriptIncluder()
Constructs a JavaScriptIncluder with a default engine, and no initial script.
|
JavaScriptIncluder(File scriptFile)
Constructs a JavaScriptIncluder with a default engine.
|
JavaScriptIncluder(File scriptFile,
ScriptEngine _engine)
Constructs a JavaScriptIncluder with the specified engine.
|
Modifier and Type | Method and Description |
---|---|
ScriptEngine |
engine()
Returns the engine in which included modules are executed.
|
void |
inc(File file)
Includes a JavaScript file by executing it in the engine.
|
void |
inc(String path)
Includes a JavaScript file by executing it in the engine.
|
Object |
invokeKnownFunction(String name,
Object... args)
The same as (Invocable)engine().
|
File |
scriptFile()
The path to the first file that was executed by inclusion.
|
public JavaScriptIncluder() throws ScriptException
ScriptException
public JavaScriptIncluder(File scriptFile) throws IOException, ScriptException
scriptFile
- to execute initially,
per scriptFile(); or null to execute noneIOException
ScriptException
public JavaScriptIncluder(File scriptFile, ScriptEngine _engine) throws IOException, ScriptException
scriptFile
- to execute initially,
per scriptFile(); or null to execute noneIOException
ScriptException
public ScriptEngine engine()
public void inc(File file) throws IOException, ScriptException
file
- the absolute path to the fileIOException
ScriptException
public void inc(String path) throws IOException, ScriptException
path
- the file's absolute or relative path,
per resolveFile(path)IOException
ScriptException
public Object invokeKnownFunction(String name, Object... args) throws ScriptException
ScriptException
public File scriptFile()
inc(String)
,
inc(File)