Package delight.rhinosandox
Interface RhinoSandbox
- All Known Implementing Classes:
RhinoSandboxImpl
public interface RhinoSandbox
-
Method Summary
Modifier and TypeMethodDescriptionWill allow access to this class in Rhino scripts.callFunction
(org.mozilla.javascript.NativeFunction function, Object[] args) executes a javascript functionEvaluate a script with its own scope.Evaluate a script with its own scope.Evaluate a script with its own scope.Evaluate a script with its own scope.evalWithGlobalScope
(String sourceName, Reader js) Evaluate the given script with the global scope.evalWithGlobalScope
(String sourceName, String js) Evaluate the given script with the global scope.Will make this class available to instantiate in Rhino scripts.Will add a global variable available to all scripts executed with this sandbox.setInstructionLimit
(int limit) Sets the maximum instructions allowed for script execution.setMaxDuration
(int limitInMs) Sets the maximum allowed duration for scripts.setUseSafeStandardObjects
(boolean useSafeStandardObject) If .initSafeStandardObjects should be used.setUseSealedScope
(boolean value) If the global scope should be sealed (default: true).
-
Method Details
-
allow
Will allow access to this class in Rhino scripts.
Note that for classes in packages which don't start with java., com., net. etc. the class name needs to be prefixed with Packages.
e.g. mypackage.Myclass will be Packages.mypackage.MyClass
-
inject
Will add a global variable available to all scripts executed with this sandbox. -
inject
Will make this class available to instantiate in Rhino scripts. -
setInstructionLimit
Sets the maximum instructions allowed for script execution. -
setMaxDuration
Sets the maximum allowed duration for scripts. -
setUseSafeStandardObjects
If .initSafeStandardObjects should be used. -
setUseSealedScope
If the global scope should be sealed (default: true). -
evalWithGlobalScope
Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts. -
evalWithGlobalScope
Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts.- Throws:
IOException
-
eval
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones. -
callFunction
executes a javascript function- Parameters:
function
- a Native function you may got from jsargs
- parameters you need to call the function- Returns:
- the result of the javascript function
-
eval
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.- Throws:
IOException
-
eval
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
variables
defines variables with Java objects which will be available for the execution of this script. -
eval
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
variables
defines variables with Java objects which will be available for the execution of this script.- Throws:
IOException
-