Skip to content

Commit edd3c34

Browse files
committed
ScriptInterpreter: add getBindings() method
This is a convenience method to easily access the engine scope bindings of the script engine.
1 parent 9b77ad3 commit edd3c34

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/org/scijava/script/DefaultScriptInterpreter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
*/
3131
package org.scijava.script;
3232

33+
import javax.script.Bindings;
34+
import javax.script.ScriptContext;
3335
import javax.script.ScriptEngine;
3436
import javax.script.ScriptException;
3537

@@ -128,4 +130,9 @@ public ScriptEngine getEngine() {
128130
return engine;
129131
}
130132

133+
@Override
134+
public Bindings getBindings() {
135+
return engine.getBindings(ScriptContext.ENGINE_SCOPE);
136+
}
137+
131138
}

src/main/java/org/scijava/script/ScriptInterpreter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
package org.scijava.script;
3333

34+
import javax.script.Bindings;
35+
import javax.script.ScriptContext;
3436
import javax.script.ScriptEngine;
3537
import javax.script.ScriptException;
3638

@@ -81,4 +83,11 @@ public interface ScriptInterpreter {
8183
* @return the script engine
8284
*/
8385
ScriptEngine getEngine();
86+
87+
/**
88+
* Returns the {@link Bindings} of the associated {@link ScriptEngine} at
89+
* {@link ScriptContext#ENGINE_SCOPE} scope.
90+
*/
91+
Bindings getBindings();
92+
8493
}

0 commit comments

Comments
 (0)