delight.rhinosandox.RhinoSandbox Maven / Gradle / Ivy
package delight.rhinosandox;
import java.io.IOException;
import java.io.Reader;
import java.util.Map;
import org.mozilla.javascript.NativeFunction;
import org.mozilla.javascript.ScriptableObject;
@SuppressWarnings("all")
public interface RhinoSandbox {
/**
* 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
*
see
*/
public abstract RhinoSandbox allow(final Class> clazz);
/**
* Will add a global variable available to all scripts executed with this sandbox.
*/
public abstract RhinoSandbox inject(final String variableName, final Object object);
/**
* Will make this class available to instantiate in Rhino scripts.
*/
public abstract RhinoSandbox inject(final Class clazz);
/**
* Sets the maximum instructions allowed for script execution.
*/
public abstract RhinoSandbox setInstructionLimit(final int limit);
/**
* Sets the maximum allowed duration for scripts.
*/
public abstract RhinoSandbox setMaxDuration(final int limitInMs);
/**
* If .initSafeStandardObjects should be used.
*/
public abstract RhinoSandbox setUseSafeStandardObjects(final boolean useSafeStandardObject);
/**
* If the global scope should be sealed (default: true).
*/
public abstract RhinoSandbox setUseSealedScope(final boolean value);
/**
* Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts.
*/
public abstract Object evalWithGlobalScope(final String sourceName, final String js);
/**
* Evaluate the given script with the global scope. That is all new global variables written will be available to all other scripts.
*/
public abstract Object evalWithGlobalScope(final String sourceName, final Reader js) throws IOException;
/**
* Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
*/
public abstract Object eval(final String sourceName, final String js);
/**
* executes a javascript function
* @param function a Native function you may got from js
* @param args parameters you need to call the function
* @return the result of the javascript function
*/
public abstract Object callFunction(NativeFunction function, Object[] args);
/**
* Evaluate a script with its own scope. It has access to all objects in the global scope but cannot add new ones.
*/
public abstract Object eval(final String sourceName, final Reader js) throws 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.
*/
public abstract Object eval(final String sourceName, final String js, final Map 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.
*/
public abstract Object eval(final String sourceName, final Reader js, final Map variables) throws IOException;
}