public class JavaScriptObject
extends java.lang.Object
JavaScriptObject cannot be created directly.
JavaScriptObject should be declared as the return type of a
JSNI method that returns native (non-Java) objects. A
JavaScriptObject passed back into JSNI from Java becomes the
original object, and can be accessed in JavaScript as expected.| Modifier | Constructor and Description |
|---|---|
protected |
JavaScriptObject()
Not directly instantiable.
|
| Modifier and Type | Method and Description |
|---|---|
<T extends JavaScriptObject> |
cast()
A helper method to enable cross-casting from any
JavaScriptObject
type to any other JavaScriptObject type. |
static JavaScriptObject |
createArray()
Returns a new array.
|
static JavaScriptObject |
createArray(int size)
Returns a new array with a given size.
|
static JavaScriptObject |
createFunction()
Returns an empty function.
|
static JavaScriptObject |
createObject()
Returns a new object.
|
boolean |
equals(java.lang.Object other)
Calls a native JS
equals method if any, otherwise
returns true if the objects are JavaScript identical
(triple-equals). |
int |
hashCode()
Calls a native JS
hashCode method if any, otherwise
uses a monotonically increasing counter to assign a hash code to the
underlying JavaScript object. |
java.lang.String |
toSource()
Call the toSource() on the JSO.
|
java.lang.String |
toString()
Makes a best-effort attempt to get a useful debugging string describing the
given JavaScriptObject.
|
protected JavaScriptObject()
public static JavaScriptObject createArray()
public static JavaScriptObject createArray(int size)
Consider using this method in performance critical code instead of using
createArray(), since this gives more hints to the underlying
JavaScript VM for optimizations.
public static JavaScriptObject createFunction()
public static JavaScriptObject createObject()
public final <T extends JavaScriptObject> T cast()
JavaScriptObject
type to any other JavaScriptObject type.T - the target typepublic final boolean equals(java.lang.Object other)
equals method if any, otherwise
returns true if the objects are JavaScript identical
(triple-equals).equals in class java.lang.Objectpublic final int hashCode()
hashCode method if any, otherwise
uses a monotonically increasing counter to assign a hash code to the
underlying JavaScript object. Do not call this method on non-modifiable
JavaScript objects.hashCode in class java.lang.Objectpublic java.lang.String toSource()
public final java.lang.String toString()
toString in class java.lang.Object