Package delight.rhinosandox
Interface RhinoSandbox
-
- All Known Implementing Classes:
RhinoSandboxImpl
public interface RhinoSandbox
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RhinoSandbox
allow(java.lang.Class<?> clazz)
Will allow access to this class in Rhino scripts.java.lang.Object
callFunction(org.mozilla.javascript.NativeFunction function, java.lang.Object[] args)
executes a javascript functionjava.lang.Object
eval(java.lang.String sourceName, java.io.Reader js)
Evaluate a script with its own scope.java.lang.Object
eval(java.lang.String sourceName, java.io.Reader js, java.util.Map<java.lang.String,java.lang.Object> variables)
Evaluate a script with its own scope.java.lang.Object
eval(java.lang.String sourceName, java.lang.String js)
Evaluate a script with its own scope.java.lang.Object
eval(java.lang.String sourceName, java.lang.String js, java.util.Map<java.lang.String,java.lang.Object> variables)
Evaluate a script with its own scope.java.lang.Object
evalWithGlobalScope(java.lang.String sourceName, java.io.Reader js)
Evaluate the given script with the global scope.java.lang.Object
evalWithGlobalScope(java.lang.String sourceName, java.lang.String js)
Evaluate the given script with the global scope.RhinoSandbox
inject(java.lang.Class<org.mozilla.javascript.ScriptableObject> clazz)
Will make this class available to instantiate in Rhino scripts.RhinoSandbox
inject(java.lang.String variableName, java.lang.Object object)
Will add a global variable available to all scripts executed with this sandbox.RhinoSandbox
setInstructionLimit(int limit)
Sets the maximum instructions allowed for script execution.RhinoSandbox
setMaxDuration(int limitInMs)
Sets the maximum allowed duration for scripts.RhinoSandbox
setUseSafeStandardObjects(boolean useSafeStandardObject)
If .initSafeStandardObjects should be used.RhinoSandbox
setUseSealedScope(boolean value)
If the global scope should be sealed (default: true).
-
-
-
Method Detail
-
allow
RhinoSandbox allow(java.lang.Class<?> clazz)
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
RhinoSandbox inject(java.lang.String variableName, java.lang.Object object)
Will add a global variable available to all scripts executed with this sandbox.
-
inject
RhinoSandbox inject(java.lang.Class<org.mozilla.javascript.ScriptableObject> clazz)
Will make this class available to instantiate in Rhino scripts.
-
setInstructionLimit
RhinoSandbox setInstructionLimit(int limit)
Sets the maximum instructions allowed for script execution.
-
setMaxDuration
RhinoSandbox setMaxDuration(int limitInMs)
Sets the maximum allowed duration for scripts.
-
setUseSafeStandardObjects
RhinoSandbox setUseSafeStandardObjects(boolean useSafeStandardObject)
If .initSafeStandardObjects should be used.
-
setUseSealedScope
RhinoSandbox setUseSealedScope(boolean value)
If the global scope should be sealed (default: true).
-
evalWithGlobalScope
java.lang.Object evalWithGlobalScope(java.lang.String sourceName, java.lang.String js)
Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts.
-
evalWithGlobalScope
java.lang.Object evalWithGlobalScope(java.lang.String sourceName, java.io.Reader js) throws java.io.IOException
Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts.- Throws:
java.io.IOException
-
eval
java.lang.Object eval(java.lang.String sourceName, java.lang.String js)
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
-
callFunction
java.lang.Object callFunction(org.mozilla.javascript.NativeFunction function, java.lang.Object[] args)
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
java.lang.Object eval(java.lang.String sourceName, java.io.Reader js) throws java.io.IOException
Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.- Throws:
java.io.IOException
-
eval
java.lang.Object eval(java.lang.String sourceName, java.lang.String js, java.util.Map<java.lang.String,java.lang.Object> variables)
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
java.lang.Object eval(java.lang.String sourceName, java.io.Reader js, java.util.Map<java.lang.String,java.lang.Object> variables) throws java.io.IOException
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:
java.io.IOException
-
-