public abstract class JSObject extends Object
Allows Java code to manipulate JavaScript objects.
When a JavaScript object is passed or returned to Java code, it
is wrapped in an instance of JSObject
. When a
JSObject
instance is passed to the JavaScript engine,
it is unwrapped back to its original JavaScript object. The
JSObject
class provides a way to invoke JavaScript
methods and examine JavaScript properties.
Any data returned from the JavaScript engine to Java is converted to Java data types. Certain data passed to the JavaScript engine is converted to JavaScript data types.
Modifier | Constructor and Description |
---|---|
protected |
JSObject()
Constructs a new JSObject.
|
Modifier and Type | Method and Description |
---|---|
abstract Object |
call(String methodName,
Object... args)
Calls a JavaScript method.
|
abstract Object |
eval(String s)
Evaluates a JavaScript expression.
|
abstract Object |
getMember(String name)
Retrieves a named member of a JavaScript object.
|
abstract Object |
getSlot(int index)
Retrieves an indexed member of a JavaScript object.
|
static JSObject |
getWindow(Applet applet)
Deprecated.
The Applet API is deprecated. See the
java.applet package documentation for further information.
|
abstract void |
removeMember(String name)
Removes a named member of a JavaScript object.
|
abstract void |
setMember(String name,
Object value)
Sets a named member of a JavaScript object.
|
abstract void |
setSlot(int index,
Object value)
Sets an indexed member of a JavaScript object.
|
protected JSObject()
public abstract Object call(String methodName, Object... args) throws JSException
methodName
- The name of the JavaScript method to be invoked.args
- the Java objects passed as arguments to the method.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract Object eval(String s) throws JSException
s
- The JavaScript expression.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract Object getMember(String name) throws JSException
name
- The name of the JavaScript property to be accessed.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract void setMember(String name, Object value) throws JSException
name
- The name of the JavaScript property to be accessed.value
- The value of the propery.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract void removeMember(String name) throws JSException
name
- The name of the JavaScript property to be removed.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract Object getSlot(int index) throws JSException
index
- The index of the array to be accessed.JSException
- when an error is reported from the browser or
JavaScript engine.public abstract void setSlot(int index, Object value) throws JSException
index
- The index of the array to be accessed.value
- The value to setJSException
- when an error is reported from the browser or
JavaScript engine.@Deprecated(since="9") public static JSObject getWindow(Applet applet) throws JSException
applet
- The applet.null
if we are not connected to a browser.JSException
- when an error is reported from the browser or
JavaScript engine or if applet is null
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-Ubuntu+0-9b134-2ubuntu1