lcjsobj | JavaScriptSource

lcjsobj

JavaScriptSource Staff Jul 24, 2006
Previous     Contents     Index     Next     
Core JavaScript Reference 1.5





JSObject

The public final class netscape.javascript.JSObject extends Object.

java.lang.Object
   |
   +----netscape.javascript.JSObject


Description
JavaScript objects are wrapped in an instance of the class netscape.javascript.JSObject and passed to Java. JSObject allows Java to manipulate JavaScript objects.

When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of type JSObject; when a JSObject is sent from Java to JavaScript, the runtime engine unwraps it to its original JavaScript object type. The JSObject class provides a way to invoke JavaScript methods and examine JavaScript properties.

Any JavaScript data brought into Java is converted to Java data types. When the JSObject is passed back to JavaScript, the object is unwrapped and can be used by JavaScript code. See the Core JavaScript Guide for more information about data type conversions.


Method Summary
The netscape.javascript.JSObject class has the following methods:



Method

Description

call

 

Calls a JavaScript method.  

equals

 

Determines if two JSObject objects refer to the same instance.  

eval

 

Evaluates a JavaScript expression.  

getMember

 

Retrieves the value of a property of a JavaScript object.  

getSlot

 

Retrieves the value of an array element of a JavaScript object.  

removeMember

 

Removes a property of a JavaScript object.  

setMember

 

Sets the value of a property of a JavaScript object.  

setSlot

 

Sets the value of an array element of a JavaScript object.  

toString

 

Converts a JSObject to a string.  

The netscape.javascript.JSObject class has the following static methods:



Method

Description

getWindow

 

Gets a JSObject for the window containing the given applet.  

The following sections show the declaration and usage of these methods.

call

Method. Calls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.


Declaration
public Object call(String methodName,
   Object args[])

equals

Method. Determines if two JSObject objects refer to the same instance.

Overrides: equals in class java.lang.Object


Declaration
public boolean equals(Object obj)


Backward Compatibility
JavaScript 1.3. In JavaScript 1.3 and earlier versions, you can use either the equals method of java.lang.Object or the == operator to evaluate two JSObject objects.

In more recent versions, the same JSObject can appear as different Java objects. You can use the equals method to determine whether two JSObjects refer to the same instance.


eval

Method. Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".


Declaration
public Object eval(String s)


getMember

Method. Retrieves the value of a property of a JavaScript object. Equivalent to "this.name" in JavaScript.


Declaration
public Object getMember(String name)


getSlot

Method. Retrieves the value of an array element of a JavaScript object. Equivalent to "this[index]" in JavaScript.


Declaration
public Object getSlot(int index)


getWindow

Static method. Returns a JSObject for the window containing the given applet. This method is useful in client-side JavaScript only.


Declaration
public static JSObject getWindow(Applet applet)


removeMember

Method. Removes a property of a JavaScript object.


Declaration
public void removeMember(String name)


setMember

Method. Sets the value of a property of a JavaScript object. Equivalent to "this.name = value" in JavaScript.


Declaration
public void setMember(String name,
   Object value)


setSlot

Method. Sets the value of an array element of a JavaScript object. Equivalent to "this[index] = value" in JavaScript.


Declaration
public void setSlot(int index,
   Object value)


toString

Method. Converts a JSObject to a String.

Overrides: toString in class java.lang.Object


Declaration
public String toString()


Previous     Contents     Index     Next     
Content is available under these licenses.
Last Updated September 28, 2000

Leave a Response

(0 comments)