public class JSContext extends JSObject
Modifier and Type | Class and Description |
---|---|
static interface |
JSContext.IJSExceptionHandler
Object interface for handling JSExceptions.
|
JSObject.jsexport, JSObject.Property<T>
JSPropertyAttributeDontDelete, JSPropertyAttributeDontEnum, JSPropertyAttributeNone, JSPropertyAttributeReadOnly
Constructor and Description |
---|
JSContext()
Creates a new JavaScript context
|
JSContext(java.lang.Class<?> iface)
Creates a JavaScript context, and defines the global object with interface 'iface'.
|
JSContext(JSContextGroup inGroup)
Creates a new JavaScript context in the context group 'inGroup'.
|
JSContext(JSContextGroup inGroup,
java.lang.Class<?> iface)
Creates a JavaScript context in context group 'inGroup', and defines the global object
with interface 'iface'.
|
Modifier and Type | Method and Description |
---|---|
void |
async(java.lang.Runnable runnable) |
void |
clearExceptionHandler()
Clears a previously set exception handler.
|
java.lang.Long |
ctxRef()
Gets the JavaScriptCore context reference
|
static void |
dummy()
Forces static libraries to load
|
JSValue |
evaluateScript(java.lang.String script)
Executes a the JavaScript code in 'script' in this context
|
JSValue |
evaluateScript(java.lang.String script,
java.lang.String sourceURL,
int startingLineNumber)
Executes a the JavaScript code in 'script' in this context
|
JSContextGroup |
getGroup()
Gets the context group to which this context belongs.
|
long |
getJSCContext() |
java.lang.Boolean |
isOnThread() |
void |
setExceptionHandler(JSContext.IJSExceptionHandler handler)
Sets the JS exception handler for this context.
|
void |
sync(java.lang.Runnable runnable) |
void |
throwJSException(JSException exception)
If an exception handler is set, calls the exception handler, otherwise throws
the JSException.
|
__nullFunc, deleteProperty, getThis, hashCode, hasProperty, isConstructor, isFunction, property, property, property, propertyAtIndex, propertyAtIndex, propertyNames, prototype, prototype
equals, getContext, isArray, isBoolean, isDate, isEqual, isInstanceOfConstructor, isNull, isNumber, isObject, isStrictEqual, isString, isUndefined, toBoolean, toFunction, toJSArray, toJSON, toJSON, toNumber, toObject, toString, valueRef
public JSContext()
public JSContext(JSContextGroup inGroup)
inGroup
- The context group to create the context inpublic JSContext(java.lang.Class<?> iface)
iface
- The interface to expose to JavaScriptpublic JSContext(JSContextGroup inGroup, java.lang.Class<?> iface)
inGroup
- The context group to create the context iniface
- The interface to expose to JavaScriptpublic static void dummy()
public void sync(java.lang.Runnable runnable)
public void async(java.lang.Runnable runnable)
public java.lang.Boolean isOnThread()
public long getJSCContext()
public void setExceptionHandler(JSContext.IJSExceptionHandler handler)
handler
- An object that implements 'IJSExceptionHandler'public void clearExceptionHandler()
public void throwJSException(JSException exception)
exception
- The JSException to be thrownpublic JSContextGroup getGroup()
public java.lang.Long ctxRef()
public JSValue evaluateScript(@NonNull java.lang.String script, java.lang.String sourceURL, int startingLineNumber)
script
- The code to executesourceURL
- The URI of the source file, only used for reporting in stack trace (optional)startingLineNumber
- The beginning line number, only used for reporting in stack trace (optional)public JSValue evaluateScript(java.lang.String script)
script
- The code to execute