@Exported public abstract class AbstractJSObject extends Object implements JSObject
Constructor and Description |
---|
AbstractJSObject()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
call(Object thiz,
Object... args)
Call this object as a JavaScript function.
|
Object |
eval(String s)
Evaluate a JavaScript expression.
|
String |
getClassName()
ECMA [[Class]] property
|
Object |
getDefaultValue(Class<?> hint)
Implements this object's
[[DefaultValue]] method. |
static Object |
getDefaultValue(JSObject jsobj,
Class<?> hint)
When passed an
AbstractJSObject , invokes its getDefaultValue(Class) method. |
Object |
getMember(String name)
Retrieves a named member of this JavaScript object.
|
Object |
getSlot(int index)
Retrieves an indexed member of this JavaScript object.
|
boolean |
hasMember(String name)
Does this object have a named member?
|
boolean |
hasSlot(int slot)
Does this object have a indexed property?
|
boolean |
isArray()
Is this an array object?
|
boolean |
isFunction()
Is this a function object?
|
boolean |
isInstance(Object instance)
Checking whether the given object is an instance of 'this' object.
|
boolean |
isInstanceOf(Object clazz)
Checking whether this object is an instance of the given 'clazz' object.
|
boolean |
isStrictFunction()
Is this a 'use strict' function object?
|
Set<String> |
keySet()
Returns the set of all property names of this object.
|
Object |
newObject(Object... args)
Call this 'constructor' JavaScript function to create a new object.
|
void |
removeMember(String name)
Remove a named member from this JavaScript object
|
void |
setMember(String name,
Object value)
Set a named member in this JavaScript object
|
void |
setSlot(int index,
Object value)
Set an indexed member in this JavaScript object
|
double |
toNumber()
Deprecated.
use
getDefaultValue(Class) with Number hint instead. |
Collection<Object> |
values()
Returns the set of all property values of this object.
|
public Object call(Object thiz, Object... args)
JSObject
public Object newObject(Object... args)
JSObject
public Object eval(String s)
JSObject
public Object getMember(String name)
JSObject
public Object getSlot(int index)
JSObject
public boolean hasMember(String name)
JSObject
public boolean hasSlot(int slot)
JSObject
public void removeMember(String name)
JSObject
removeMember
in interface JSObject
name
- name of the memberpublic void setMember(String name, Object value)
JSObject
public void setSlot(int index, Object value)
JSObject
public Set<String> keySet()
JSObject
public Collection<Object> values()
JSObject
public boolean isInstance(Object instance)
JSObject
isInstance
in interface JSObject
instance
- instance to checkpublic boolean isInstanceOf(Object clazz)
JSObject
isInstanceOf
in interface JSObject
clazz
- clazz to checkpublic String getClassName()
JSObject
getClassName
in interface JSObject
public boolean isFunction()
JSObject
isFunction
in interface JSObject
public boolean isStrictFunction()
JSObject
isStrictFunction
in interface JSObject
public boolean isArray()
JSObject
@Deprecated public double toNumber()
getDefaultValue(Class)
with Number
hint instead.public Object getDefaultValue(Class<?> hint)
[[DefaultValue]]
method. The default implementation follows ECMAScript 5.1
section 8.6.2 but subclasses are free to provide their own implementations.hint
- the type hint. Should be either null
, Number.class
or String.class
.UnsupportedOperationException
- if the conversion can't be performed. The engine will convert this
exception into a JavaScript TypeError
.public static Object getDefaultValue(JSObject jsobj, Class<?> hint)
AbstractJSObject
, invokes its getDefaultValue(Class)
method. When passed any
other JSObject
, it will obtain its [[DefaultValue]]
method as per ECMAScript 5.1 section
8.6.2.jsobj
- the JSObject
whose [[DefaultValue]]
is obtained.hint
- the type hint. Should be either null
, Number.class
or String.class
.UnsupportedOperationException
- if the conversion can't be performed. The engine will convert this
exception into a JavaScript TypeError
.
Copyright © 2014, 2016, Oracle and/or its affiliates. All rights reserved.