Class netscape.javascript.JSObject
All Packages This Package Previous Next Index
Class netscape.javascript.JSObject
java.lang.Object
|
+----netscape.javascript.JSObject
- public final class JSObject
- extends Object
JSObject allows Java to manipulate objects that are
defined in JavaScript.
Values passed from Java to JavaScript are converted as
follows:
- JSObject is converted to the original JavaScript object
- Any other Java object is converted to a JavaScript wrapper,
which can be used to access methods and fields of the java object.
Converting this wrapper to a string will call the toString method
on the original object, converting to a number will call the
floatValue method if possible and fail otherwise. Converting
to a boolean will try to call the booleanValue method in the
same way.
- Java arrays are wrapped with a JavaScript object that understands
array.length and array[index]
- A Java boolean is converted to a JavaScript boolean
- Java byte, char, short, int, long, float, and double are converted
to JavaScript numbers
Values passed from JavaScript to Java are converted as follows:
- objects which are wrappers around java objects are unwrapped
- other objects are wrapped with a JSObject
- strings, numbers and booleans are converted to String, Float,
and Boolean objects respectively
This means that all JavaScript values show up as some kind
of java.lang.Object in Java. In order to make much use of them,
you will have to cast them to the appropriate subclass of Object,
e.g. (String) window.getMember("name");
or
(JSObject) window.getMember("document");
.
-
call(String, Object[])
- Calls a JavaScript method.
-
eval(String)
- Evaluates a JavaScript expression.
-
finalize()
- Finalization decrements the reference count on the corresponding
JavaScript object.
-
getMember(String)
- Retrieves a named member of a JavaScript object.
-
getSlot(int)
- Retrieves an indexed member of a JavaScript object.
-
getWindow(Applet)
- get a JSObject for the window containing the given applet
-
removeMember(String)
- Removes a named member of a JavaScript object.
-
setMember(String, Object)
- Sets a named member of a JavaScript object.
-
setSlot(int, Object)
- Sets an indexed member of a JavaScript object.
-
toString()
- Converts a JSObject to a String.
getMember
public Object getMember(String name)
- Retrieves a named member of a JavaScript object.
Equivalent to "this.name" in JavaScript.
getSlot
public Object getSlot(int index)
- Retrieves an indexed member of a JavaScript object.
Equivalent to "this[index]" in JavaScript.
setMember
public void setMember(String name,
Object value)
- Sets a named member of a JavaScript object.
Equivalent to "this.name = value" in JavaScript.
setSlot
public void setSlot(int index,
Object value)
- Sets an indexed member of a JavaScript object.
Equivalent to "this[index] = value" in JavaScript.
removeMember
public void removeMember(String name)
- Removes a named member of a JavaScript object.
call
public Object call(String methodName,
Object args[])
- Calls a JavaScript method.
Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.
eval
public Object eval(String s)
- Evaluates a JavaScript expression. The expression is a string
of JavaScript source code which will be evaluated in the context
given by "this".
toString
public String toString()
- Converts a JSObject to a String.
- Overrides:
- toString in class Object
getWindow
public static JSObject getWindow(Applet applet)
- get a JSObject for the window containing the given applet
finalize
protected void finalize()
- Finalization decrements the reference count on the corresponding
JavaScript object.
- Overrides:
- finalize in class Object
All Packages This Package Previous Next Index