Top Description Constructors Methods
netscape.javascript

public abstract Class JSObject

extends Object
Class Inheritance

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.

Since
1.5

Constructor Summary

AccessConstructor and Description
protected
JSObject()

Constructs a new JSObject.

Method Summary

Modifier and TypeMethod and Description
public abstract Object

Returns:

Result of the method.
call
(String
The name of the JavaScript method to be invoked.
methodName
,
Object...
the Java objects passed as arguments to the method.
args
)

Calls a JavaScript method.

public abstract Object

Returns:

Result of the JavaScript evaluation.
eval
(String
The JavaScript expression.
s
)

Evaluates a JavaScript expression.

public abstract Object

Returns:

The value of the property.
getMember
(String
The name of the JavaScript property to be accessed.
name
)

Retrieves a named member of a JavaScript object.

public abstract Object

Returns:

The value of the indexed member.
getSlot
(int
The index of the array to be accessed.
index
)

Retrieves an indexed member of a JavaScript object.

public abstract void
removeMember(String
The name of the JavaScript property to be removed.
name
)

Removes a named member of a JavaScript object.

public abstract void
setMember(String
The name of the JavaScript property to be accessed.
name
,
Object
The value of the property.
value
)

Sets a named member of a JavaScript object.

public abstract void
setSlot(int
The index of the array to be accessed.
index
,
Object
The value to set
value
)

Sets an indexed member of a JavaScript object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JSObjectback to summary
protected JSObject()

Constructs a new JSObject. Users should neither call this method nor subclass JSObject.

Method Detail

callback to summary
public abstract Object call(String methodName, Object... args) throws JSException

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

Parameters
methodName:String

The name of the JavaScript method to be invoked.

args:Object[]

the Java objects passed as arguments to the method.

Returns:Object

Result of the method.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
evalback to summary
public abstract Object eval(String s) throws JSException

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

Parameters
s:String

The JavaScript expression.

Returns:Object

Result of the JavaScript evaluation.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
getMemberback to summary
public abstract Object getMember(String name) throws JSException

Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.

Parameters
name:String

The name of the JavaScript property to be accessed.

Returns:Object

The value of the property.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
getSlotback to summary
public abstract Object getSlot(int index) throws JSException

Retrieves an indexed member of a JavaScript object. Equivalent to "this[index]" in JavaScript.

Parameters
index:int

The index of the array to be accessed.

Returns:Object

The value of the indexed member.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
removeMemberback to summary
public abstract void removeMember(String name) throws JSException

Removes a named member of a JavaScript object. Equivalent to "delete this.name" in JavaScript.

Parameters
name:String

The name of the JavaScript property to be removed.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
setMemberback to summary
public abstract void setMember(String name, Object value) throws JSException

Sets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.

Parameters
name:String

The name of the JavaScript property to be accessed.

value:Object

The value of the property.

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.
setSlotback to summary
public abstract void setSlot(int index, Object value) throws JSException

Sets an indexed member of a JavaScript object. Equivalent to "this[index] = value" in JavaScript.

Parameters
index:int

The index of the array to be accessed.

value:Object

The value to set

Exceptions
JSException:
when an error is reported from the browser or JavaScript engine.