Class AbstractJSObject
- java.lang.Object
-
- jdk.nashorn.api.scripting.AbstractJSObject
- All Implemented Interfaces:
JSObject
- Direct Known Subclasses:
ScriptObjectMirror
@Deprecated(since="11",
forRemoval=true)
public abstract class AbstractJSObject
extends Object
implements JSObject 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
Constructors
| Constructor | Description |
|---|---|
AbstractJSObject() | Deprecated, for removal: This API element is subject to removal in a future version. The default constructor. |
Methods
| Modifier and Type | Method | Description |
|---|---|---|
Object | call(Object thiz,
Object... args) | Deprecated, for removal: This API element is subject to removal in a future version. Call this object as a JavaScript function. |
Object | eval(String s) | Deprecated, for removal: This API element is subject to removal in a future version. Evaluate a JavaScript expression. |
static Object | getDefaultValue(JSObject jsobj,
Class<?> hint) | Deprecated. use JSObject.getDefaultValue(Class) instead. |
Object | getMember(String name) | Deprecated, for removal: This API element is subject to removal in a future version. Retrieves a named member of this JavaScript object. |
Object | getSlot(int index) | Deprecated, for removal: This API element is subject to removal in a future version. Retrieves an indexed member of this JavaScript object. |
boolean | hasMember(String name) | Deprecated, for removal: This API element is subject to removal in a future version. Does this object have a named member? |
boolean | hasSlot(int slot) | Deprecated, for removal: This API element is subject to removal in a future version. Does this object have a indexed property? |
boolean | isArray() | Deprecated, for removal: This API element is subject to removal in a future version. Is this an array object? |
boolean | isFunction() | Deprecated, for removal: This API element is subject to removal in a future version. Is this a function object? |
boolean | isInstance(Object instance) | Deprecated, for removal: This API element is subject to removal in a future version. Checking whether the given object is an instance of 'this' object. |
boolean | isStrictFunction() | Deprecated, for removal: This API element is subject to removal in a future version. Is this a 'use strict' function object? |
Set<String> | keySet() | Deprecated, for removal: This API element is subject to removal in a future version. Returns the set of all property names of this object. |
Object | newObject(Object... args) | Deprecated, for removal: This API element is subject to removal in a future version. Call this 'constructor' JavaScript function to create a new object. |
void | removeMember(String name) | Deprecated, for removal: This API element is subject to removal in a future version. Remove a named member from this JavaScript object |
void | setMember(String name,
Object value) | Deprecated, for removal: This API element is subject to removal in a future version. Set a named member in this JavaScript object |
void | setSlot(int index,
Object value) | Deprecated, for removal: This API element is subject to removal in a future version. Set an indexed member in this JavaScript object |
double | toNumber() | Deprecated. use JSObject.getDefaultValue(Class) with Number hint instead. |
Collection<Object> | values() | Deprecated, for removal: This API element is subject to removal in a future version. Returns the set of all property values of this object. |
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Methods declared in interface jdk.nashorn.api.scripting.JSObject
getClassName, getDefaultValue, isInstanceOf Constructors
AbstractJSObject
public AbstractJSObject()
The default constructor.
Methods
call
public Object call(Object thiz,
Object... args) Description copied from interface: JSObject
Call this object as a JavaScript function. This is equivalent to 'func.apply(thiz, args)' in JavaScript.
- Specified by:
-
callin interfaceJSObject - Implementation Requirements:
- This implementation always throws UnsupportedOperationException
- Parameters:
-
thiz- 'this' object to be passed to the function. This may be null. -
args- arguments to method - Returns:
- result of call
newObject
public Object newObject(Object... args)
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.
- Specified by:
-
newObjectin interfaceJSObject - Implementation Requirements:
- This implementation always throws UnsupportedOperationException
- Parameters:
-
args- arguments to method - Returns:
- result of constructor call
eval
public Object eval(String s)
Description copied from interface: JSObject
Evaluate a JavaScript expression.
- Specified by:
-
evalin interfaceJSObject - Implementation Requirements:
- This imlementation always throws UnsupportedOperationException
- Parameters:
-
s- JavaScript expression to evaluate - Returns:
- evaluation result
getMember
public Object getMember(String name)
Description copied from interface: JSObject
Retrieves a named member of this JavaScript object.
- Specified by:
-
getMemberin interfaceJSObject - Implementation Requirements:
- This implementation always returns null
- Parameters:
-
name- of member - Returns:
- member
getSlot
public Object getSlot(int index)
Description copied from interface: JSObject
Retrieves an indexed member of this JavaScript object.
- Specified by:
-
getSlotin interfaceJSObject - Implementation Requirements:
- This implementation always returns null
- Parameters:
-
index- index slot to retrieve - Returns:
- member
hasMember
public boolean hasMember(String name)
Description copied from interface: JSObject
Does this object have a named member?
- Specified by:
-
hasMemberin interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Parameters:
-
name- name of member - Returns:
- true if this object has a member of the given name
hasSlot
public boolean hasSlot(int slot)
Description copied from interface: JSObject
Does this object have a indexed property?
- Specified by:
-
hasSlotin interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Parameters:
-
slot- index to check - Returns:
- true if this object has a slot
removeMember
public void removeMember(String name)
Description copied from interface: JSObject
Remove a named member from this JavaScript object
- Specified by:
-
removeMemberin interfaceJSObject - Implementation Requirements:
- This implementation is a no-op
- Parameters:
-
name- name of the member
setMember
public void setMember(String name,
Object value) Description copied from interface: JSObject
Set a named member in this JavaScript object
- Specified by:
-
setMemberin interfaceJSObject - Implementation Requirements:
- This implementation is a no-op
- Parameters:
-
name- name of the member -
value- value of the member
setSlot
public void setSlot(int index,
Object value) Description copied from interface: JSObject
Set an indexed member in this JavaScript object
- Specified by:
-
setSlotin interfaceJSObject - Implementation Requirements:
- This implementation is a no-op
- Parameters:
-
index- index of the member slot -
value- value of the member
keySet
public Set<String> keySet()
Description copied from interface: JSObject
Returns the set of all property names of this object.
- Specified by:
-
keySetin interfaceJSObject - Implementation Requirements:
- This implementation returns empty set
- Returns:
- set of property names
values
public Collection<Object> values()
Description copied from interface: JSObject
Returns the set of all property values of this object.
- Specified by:
-
valuesin interfaceJSObject - Implementation Requirements:
- This implementation returns empty set
- Returns:
- set of property values.
isInstance
public boolean isInstance(Object instance)
Description copied from interface: JSObject
Checking whether the given object is an instance of 'this' object.
- Specified by:
-
isInstancein interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Parameters:
-
instance- instance to check - Returns:
- true if the given 'instance' is an instance of this 'function' object
isFunction
public boolean isFunction()
Description copied from interface: JSObject
Is this a function object?
- Specified by:
-
isFunctionin interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Returns:
- if this mirror wraps a ECMAScript function instance
isStrictFunction
public boolean isStrictFunction()
Description copied from interface: JSObject
Is this a 'use strict' function object?
- Specified by:
-
isStrictFunctionin interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Returns:
- true if this mirror represents a ECMAScript 'use strict' function
isArray
public boolean isArray()
Description copied from interface: JSObject
Is this an array object?
- Specified by:
-
isArrayin interfaceJSObject - Implementation Requirements:
- This implementation always returns false
- Returns:
- if this mirror wraps a ECMAScript array object
toNumber
@Deprecated public double toNumber()
JSObject.getDefaultValue(Class) with Number hint instead.Returns this object's numeric value.
getDefaultValue
@Deprecated
public static Object getDefaultValue(JSObject jsobj,
Class<?> hint) JSObject.getDefaultValue(Class) instead.When passed an AbstractJSObject, invokes its JSObject.getDefaultValue(Class) method. When passed any other JSObject, it will obtain its [[DefaultValue]] method as per ECMAScript 5.1 section 8.6.2.
- Parameters:
-
jsobj- theJSObjectwhose[[DefaultValue]]is obtained. -
hint- the type hint. Should be eithernull,Number.classorString.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.
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.scripting.nashorn/jdk/nashorn/api/scripting/AbstractJSObject.html