Package ch.obermuhlner.scriptengine.java
Class JavaCompiledScript
- java.lang.Object
-
- javax.script.CompiledScript
-
- ch.obermuhlner.scriptengine.java.JavaCompiledScript
-
public class JavaCompiledScript extends javax.script.CompiledScriptThe compiled Java script created by aJavaScriptEngine.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>compiledClassprivate java.lang.ObjectcompiledInstanceprivate JavaScriptEngineengineprivate ExecutionStrategyexecutionStrategy
-
Constructor Summary
Constructors Constructor Description JavaCompiledScript(JavaScriptEngine engine, java.lang.Class<?> compiledClass, java.lang.Object compiledInstance, ExecutionStrategy executionStrategy)Construct aJavaCompiledScript.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Objecteval(javax.script.ScriptContext context)java.lang.Class<?>getCompiledClass()Returns the compiledClass.java.lang.ObjectgetCompiledInstance()Returns the instance of the compiledClass.javax.script.ScriptEnginegetEngine()java.lang.ObjectgetInstance()Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledInstance()instead.java.lang.Class<?>getInstanceClass()Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledClass()instead.private java.util.Map<java.lang.String,java.lang.Object>mergeBindings(javax.script.Bindings... bindingsToMerge)private voidpullVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings)private voidpushVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings)private voidsetBindingsValue(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings, java.lang.String name, java.lang.Object value)voidsetExecutionStrategy(ExecutionStrategy executionStrategy)Sets theExecutionStrategyto be used when evaluating the compiled class instance.
-
-
-
Field Detail
-
engine
private final JavaScriptEngine engine
-
compiledClass
private final java.lang.Class<?> compiledClass
-
compiledInstance
private final java.lang.Object compiledInstance
-
executionStrategy
private ExecutionStrategy executionStrategy
-
-
Constructor Detail
-
JavaCompiledScript
JavaCompiledScript(JavaScriptEngine engine, java.lang.Class<?> compiledClass, java.lang.Object compiledInstance, ExecutionStrategy executionStrategy)
Construct aJavaCompiledScript.- Parameters:
engine- theJavaScriptEnginethat compiled this scriptcompiledClass- the compiledClasscompiledInstance- the instance of the compiledClassornullif no instance was created and only static methods will be called by the theExecutionStrategy.executionStrategy- theExecutionStrategy
-
-
Method Detail
-
getCompiledClass
public java.lang.Class<?> getCompiledClass()
Returns the compiledClass.- Returns:
- the compiled
Class.
-
getCompiledInstance
public java.lang.Object getCompiledInstance()
Returns the instance of the compiledClass.- Returns:
- the instance of the compiled
Classornullif no instance was created and only static methods will be called by the theExecutionStrategy.
-
getInstanceClass
@Deprecated public java.lang.Class<?> getInstanceClass()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledClass()instead.Returns the compiledClass.- Returns:
- the compiled
Class.
-
getInstance
@Deprecated public java.lang.Object getInstance()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledInstance()instead.Returns the instance of the compiledClass.- Returns:
- the instance of the compiled
Classornullif no instance was created and only static methods will be called by the theExecutionStrategy.
-
setExecutionStrategy
public void setExecutionStrategy(ExecutionStrategy executionStrategy)
Sets theExecutionStrategyto be used when evaluating the compiled class instance.- Parameters:
executionStrategy- theExecutionStrategy
-
getEngine
public javax.script.ScriptEngine getEngine()
- Specified by:
getEnginein classjavax.script.CompiledScript
-
eval
public java.lang.Object eval(javax.script.ScriptContext context) throws javax.script.ScriptException- Specified by:
evalin classjavax.script.CompiledScript- Throws:
javax.script.ScriptException
-
pushVariables
private void pushVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings) throws javax.script.ScriptException- Throws:
javax.script.ScriptException
-
pullVariables
private void pullVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings) throws javax.script.ScriptException- Throws:
javax.script.ScriptException
-
setBindingsValue
private void setBindingsValue(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings, java.lang.String name, java.lang.Object value)
-
mergeBindings
private java.util.Map<java.lang.String,java.lang.Object> mergeBindings(javax.script.Bindings... bindingsToMerge)
-
-