public final class Duktape
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release the native resources associated with this object.
|
static Duktape |
create()
Create a new interpreter instance.
|
java.lang.Object |
evaluate(java.lang.String script)
Evaluate
script and return a result. |
java.lang.Object |
evaluate(java.lang.String script,
java.lang.String fileName)
Evaluate
script and return a result. |
protected void |
finalize() |
<T> T |
get(java.lang.String name,
java.lang.Class<T> type)
Attaches to a global JavaScript object called
name that implements type. |
<T> void |
set(java.lang.String name,
java.lang.Class<T> type,
T object)
Provides
object to JavaScript as a global object called name. |
public static Duktape create()
close() on the returned instance to avoid leaking native memory.public java.lang.Object evaluate(java.lang.String script,
java.lang.String fileName)
script and return a result. fileName will be used in error
reporting. Note that the result must be one of the supported Java types or the call will
return null.DuktapeException - if there is an error evaluating the script.public java.lang.Object evaluate(java.lang.String script)
script and return a result. Note that the result must be one of the
supported Java types or the call will return null.DuktapeException - if there is an error evaluating the script.public <T> void set(java.lang.String name,
java.lang.Class<T> type,
T object)
object to JavaScript as a global object called name. type
defines the interface implemented by object that will be accessible to JavaScript.
type must be an interface that does not extend any other interfaces, and cannot define
any overloaded methods.
Methods of the interface may return void or any of the following supported argument
types: boolean, Boolean, int, Integer, double,
Double, String.
public <T> T get(java.lang.String name,
java.lang.Class<T> type)
name that implements type.
type defines the interface implemented in JavaScript that will be accessible to Java.
type must be an interface that does not extend any other interfaces, and cannot define
any overloaded methods.
Methods of the interface may return void or any of the following supported argument
types: boolean, Boolean, int, Integer, double,
Double, String.
public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable