Class CompiledScript
java.lang.Object
javax.script.CompiledScript
Extended by classes that store results of compilations. State
might be stored in the form of Java classes, Java class files or scripting
language opcodes. The script may be executed repeatedly
without reparsing.
Each
Each
CompiledScript is associated with a ScriptEngine -- A call to an eval
method of the CompiledScript causes the execution of the script by the
ScriptEngine. Changes in the state of the ScriptEngine caused by execution
of the CompiledScript may visible during subsequent executions of scripts by the engine.- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneval()Executes the program stored in theCompiledScriptobject.Executes the program stored in theCompiledScriptobject using the suppliedBindingsof attributes as theENGINE_SCOPEof the associatedScriptEngineduring script execution.abstract Objecteval(ScriptContext context) Executes the program stored in thisCompiledScriptobject.abstract ScriptEngineReturns theScriptEnginewhosecompilemethod created thisCompiledScript.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
CompiledScript
public CompiledScript()Constructor for subclasses to call.
-
-
Method Details
-
eval
Executes the program stored in thisCompiledScriptobject.- Parameters:
context- AScriptContextthat is used in the same way as theScriptContextpassed to theevalmethods ofScriptEngine.- Returns:
- The value returned by the script execution, if any. Should return
nullif no value is returned by the script execution. - Throws:
ScriptException- if an error occurs.NullPointerException- if context is null.
-
eval
Executes the program stored in theCompiledScriptobject using the suppliedBindingsof attributes as theENGINE_SCOPEof the associatedScriptEngineduring script execution. If bindings is null, then the effect of calling this method is same as that of eval(getEngine().getContext()).. The
GLOBAL_SCOPEBindings,ReaderandWriterassociated with the defaultScriptContextof the associatedScriptEngineare used.- Parameters:
bindings- The bindings of attributes used for theENGINE_SCOPE.- Returns:
- The return value from the script execution
- Throws:
ScriptException- if an error occurs.
-
eval
Executes the program stored in theCompiledScriptobject. The defaultScriptContextof the associatedScriptEngineis used. The effect of calling this method is same as that of eval(getEngine().getContext()).- Returns:
- The return value from the script execution
- Throws:
ScriptException- if an error occurs.
-
getEngine
Returns theScriptEnginewhosecompilemethod created thisCompiledScript. TheCompiledScriptwill execute in this engine.- Returns:
- The
ScriptEnginethat created thisCompiledScript
-