java.lang.Object
org.openjdk.nashorn.api.scripting.AbstractJSObject
- All Implemented Interfaces:
JSObject
- Direct Known Subclasses:
ScriptObjectMirror
This is the base class for nashorn ScriptObjectMirror class.
This class can also be subclassed by an arbitrary Java class. Nashorn will
treat objects of such classes just like nashorn script objects. Usual nashorn
operations like obj[i], obj.foo, obj.func(), delete obj.foo will be delegated
to appropriate method call of this class.
- Since:
- 1.8u40
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCall this object as a JavaScript function.Evaluate a JavaScript expression.ECMA [[Class]] propertystatic Object
getDefaultValue
(JSObject jsobj, Class<?> hint) Deprecated.Retrieves a named member of this JavaScript object.getSlot
(int index) Retrieves an indexed member of this JavaScript object.boolean
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
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
Is this a 'use strict' function object?keySet()
Returns the set of all property names of this object.Call this 'constructor' JavaScript function to create a new object.void
removeMember
(String name) Remove a named member from this JavaScript objectvoid
Set a named member in this JavaScript objectvoid
Set an indexed member in this JavaScript objectdouble
toNumber()
Deprecated.useJSObject.getDefaultValue(Class)
withNumber
hint instead.values()
Returns the set of all property values of this object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openjdk.nashorn.api.scripting.JSObject
getDefaultValue
-
Constructor Details
-
AbstractJSObject
public AbstractJSObject()The default constructor.
-
-
Method Details
-
call
Description copied from interface:JSObject
Call this object as a JavaScript function. This is equivalent to 'func.apply(thiz, args)' in JavaScript. -
newObject
Description copied from interface:JSObject
Call this 'constructor' JavaScript function to create a new object. This is equivalent to 'new func(arg1, arg2...)' in JavaScript. -
eval
Description copied from interface:JSObject
Evaluate a JavaScript expression. -
getMember
Description copied from interface:JSObject
Retrieves a named member of this JavaScript object. -
getSlot
Description copied from interface:JSObject
Retrieves an indexed member of this JavaScript object. -
hasMember
Description copied from interface:JSObject
Does this object have a named member? -
hasSlot
public boolean hasSlot(int slot) Description copied from interface:JSObject
Does this object have a indexed property? -
removeMember
Description copied from interface:JSObject
Remove a named member from this JavaScript object- Specified by:
removeMember
in interfaceJSObject
- Parameters:
name
- name of the member- Implementation Requirements:
- This implementation is a no-op
-
setMember
Description copied from interface:JSObject
Set a named member in this JavaScript object -
setSlot
Description copied from interface:JSObject
Set an indexed member in this JavaScript object -
keySet
Description copied from interface:JSObject
Returns the set of all property names of this object. -
values
Description copied from interface:JSObject
Returns the set of all property values of this object. -
isInstance
Description copied from interface:JSObject
Checking whether the given object is an instance of 'this' object.- Specified by:
isInstance
in interfaceJSObject
- Parameters:
instance
- instance to check- Returns:
- true if the given 'instance' is an instance of this 'function' object
- Implementation Requirements:
- This implementation always returns false
-
isInstanceOf
Description copied from interface:JSObject
Checking whether this object is an instance of the given 'clazz' object.- Specified by:
isInstanceOf
in interfaceJSObject
- Parameters:
clazz
- clazz to check- Returns:
- true if this object is an instance of the given 'clazz'
-
getClassName
Description copied from interface:JSObject
ECMA [[Class]] property- Specified by:
getClassName
in interfaceJSObject
- Returns:
- ECMA [[Class]] property value of this object
-
isFunction
public boolean isFunction()Description copied from interface:JSObject
Is this a function object?- Specified by:
isFunction
in interfaceJSObject
- Returns:
- if this mirror wraps a ECMAScript function instance
- Implementation Requirements:
- This implementation always returns false
-
isStrictFunction
public boolean isStrictFunction()Description copied from interface:JSObject
Is this a 'use strict' function object?- Specified by:
isStrictFunction
in interfaceJSObject
- Returns:
- true if this mirror represents a ECMAScript 'use strict' function
- Implementation Requirements:
- This implementation always returns false
-
isArray
public boolean isArray()Description copied from interface:JSObject
Is this an array object? -
toNumber
Deprecated.useJSObject.getDefaultValue(Class)
withNumber
hint instead.Returns this object's numeric value. -
getDefaultValue
Deprecated.useJSObject.getDefaultValue(Class)
instead.When passed anAbstractJSObject
, invokes itsJSObject.getDefaultValue(Class)
method. When passed any otherJSObject
, it will obtain its[[DefaultValue]]
method as per ECMAScript 5.1 section 8.6.2.- Parameters:
jsobj
- theJSObject
whose[[DefaultValue]]
is obtained.hint
- the type hint. Should be eithernull
,Number.class
orString.class
.- Returns:
- this object's default value.
- Throws:
UnsupportedOperationException
- if the conversion can't be performed. The engine will convert this exception into a JavaScriptTypeError
.
-
JSObject.getDefaultValue(Class)
instead.