Modifier and Type | Method and Description |
---|---|
Object |
call(Object thiz,
Object... args)
Call this object as a JavaScript function.
|
Object |
callMember(String functionName,
Object... args)
Call member function
|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified
key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the
specified value.
|
boolean |
delete(Object key)
Delete a property from this object.
|
Set<Map.Entry<String,Object>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
boolean |
equals(Object other)
Compares the argument to the receiver, and answers true
if they represent the same object using a class
specific comparison.
|
Object |
eval(String s)
Evaluate a JavaScript expression.
|
ScriptObjectMirror |
freeze()
ECMA 15.2.39 - freeze implementation.
|
Object |
get(Object key)
Returns the value to which this map maps the specified key.
|
String |
getClassName()
ECMA [[Class]] property
|
Object |
getDefaultValue(Class<?> hint)
Implements this object's
[[DefaultValue]] method. |
Object |
getMember(String name)
Retrieves a named member of this JavaScript object.
|
String[] |
getOwnKeys(boolean all)
return an array of own property keys associated with the object.
|
Object |
getOwnPropertyDescriptor(String key)
ECMA 8.12.1 [[GetOwnProperty]] (P)
|
Object |
getProto()
Return the __proto__ of this object.
|
Object |
getSlot(int index)
Retrieves an indexed member of this JavaScript object.
|
int |
hashCode()
Answers an integer hash code for the receiver.
|
boolean |
hasMember(String name)
Does this object have a named member?
|
boolean |
hasSlot(int slot)
Does this object have a indexed property?
|
static boolean |
identical(Object obj1,
Object obj2)
Are the given objects mirrors to same underlying object?
|
boolean |
isArray()
Is this an array object?
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
boolean |
isExtensible()
Check if this script object is extensible
|
boolean |
isFrozen()
Check whether this script object is frozen
|
boolean |
isFunction()
Is this a function object?
|
boolean |
isInstance(Object instance)
Checking whether the given object is an instance of 'this' object.
|
boolean |
isSealed()
Check whether this script object is sealed
|
boolean |
isStrictFunction()
Is this a 'use strict' function object?
|
static boolean |
isUndefined(Object obj)
Utility to check if given object is ECMAScript undefined value
|
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.
|
ScriptObjectMirror |
preventExtensions()
Flag this script object as non extensible
|
Object |
put(String key,
Object value)
Set a named value.
|
void |
putAll(Map<? extends String,? extends Object> map)
Adds all the mappings in a given
Map to this Bindings . |
Object |
remove(Object key)
Removes the mapping for this key from this map if it is present
(optional operation).
|
void |
removeMember(String name)
Remove a named member from this JavaScript object
|
ScriptObjectMirror |
seal()
ECMAScript 15.2.3.8 - seal implementation
|
void |
setIndexedPropertiesToExternalArrayData(ByteBuffer buf)
Nashorn extension: setIndexedPropertiesToExternalArrayData.
|
void |
setMember(String name,
Object value)
Set a named member in this JavaScript object
|
void |
setProto(Object proto)
Set the __proto__ of this object.
|
void |
setSlot(int index,
Object value)
Set an indexed member in this JavaScript object
|
int |
size()
Returns the number of key-value mappings in this map.
|
<T> T |
to(Class<T> type)
Utility to convert this script object to the given type.
|
double |
toNumber()
Deprecated.
|
String |
toString()
Answers a string containing a concise, human-readable
description of the receiver.
|
static Object |
unwrap(Object obj,
Object homeGlobal)
Unwrap a script object mirror if needed.
|
static Object[] |
unwrapArray(Object[] args,
Object homeGlobal)
Unwrap an array of script object mirrors if needed.
|
Collection<Object> |
values()
Returns the set of all property values of this object.
|
static Object |
wrap(Object obj,
Object homeGlobal)
Make a script object mirror on given object if needed.
|
static Object[] |
wrapArray(Object[] args,
Object homeGlobal)
Wrap an array of object to script object mirrors if needed.
|
static Object |
wrapAsJSONCompatible(Object obj,
Object homeGlobal)
Make a script object mirror on given object if needed.
|
getDefaultValue, isInstanceOf
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public boolean equals(Object other)
java.lang.Object
public int hashCode()
java.lang.Object
true
when passed to
.equals
must answer the same value for this
method.public String toString()
java.lang.Object
public Object call(Object thiz, Object... args)
JSObject
call
in interface JSObject
call
in class AbstractJSObject
thiz
- 'this' object to be passed to the function. This may be null.args
- arguments to methodpublic Object newObject(Object... args)
JSObject
newObject
in interface JSObject
newObject
in class AbstractJSObject
args
- arguments to methodpublic Object eval(String s)
JSObject
eval
in interface JSObject
eval
in class AbstractJSObject
s
- JavaScript expression to evaluatepublic Object callMember(String functionName, Object... args)
functionName
- function nameargs
- argumentspublic Object getMember(String name)
JSObject
getMember
in interface JSObject
getMember
in class AbstractJSObject
name
- of memberpublic Object getSlot(int index)
JSObject
getSlot
in interface JSObject
getSlot
in class AbstractJSObject
index
- index slot to retrievepublic boolean hasMember(String name)
JSObject
hasMember
in interface JSObject
hasMember
in class AbstractJSObject
name
- name of memberpublic boolean hasSlot(int slot)
JSObject
hasSlot
in interface JSObject
hasSlot
in class AbstractJSObject
slot
- index to checkpublic void removeMember(String name)
JSObject
removeMember
in interface JSObject
removeMember
in class AbstractJSObject
name
- name of the memberpublic void setMember(String name, Object value)
JSObject
setMember
in interface JSObject
setMember
in class AbstractJSObject
name
- name of the membervalue
- value of the memberpublic void setSlot(int index, Object value)
JSObject
setSlot
in interface JSObject
setSlot
in class AbstractJSObject
index
- index of the member slotvalue
- value of the memberpublic void setIndexedPropertiesToExternalArrayData(ByteBuffer buf)
buf
- external buffer - should be a nio ByteBufferpublic boolean isInstance(Object instance)
JSObject
isInstance
in interface JSObject
isInstance
in class AbstractJSObject
instance
- instance to checkpublic String getClassName()
JSObject
getClassName
in interface JSObject
getClassName
in class AbstractJSObject
public boolean isFunction()
JSObject
isFunction
in interface JSObject
isFunction
in class AbstractJSObject
public boolean isStrictFunction()
JSObject
isStrictFunction
in interface JSObject
isStrictFunction
in class AbstractJSObject
public boolean isArray()
JSObject
isArray
in interface JSObject
isArray
in class AbstractJSObject
public void clear()
java.util.Map
public boolean containsKey(Object key)
javax.script.Bindings
containsKey
in interface Map<String,Object>
containsKey
in interface Bindings
key
- key whose presence in this map is to be tested.public boolean containsValue(Object value)
java.util.Map
containsValue
in interface Map<String,Object>
value
- value whose presence in this map is to be testedpublic Set<Map.Entry<String,Object>> entrySet()
java.util.Map
Set
view of the mappings contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. If the map is modified
while an iteration over the set is in progress (except through
the iterator's own remove operation, or through the
setValue operation on a map entry returned by the
iterator) the results of the iteration are undefined. The set
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Set.remove, removeAll, retainAll and
clear operations. It does not support the
add or addAll operations.public Object get(Object key)
javax.script.Bindings
More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)
public boolean isEmpty()
java.util.Map
public Set<String> keySet()
JSObject
public Object put(String key, Object value)
javax.script.Bindings
put
in interface Map<String,Object>
put
in interface Bindings
key
- The name associated with the value.value
- The value associated with the name.public void putAll(Map<? extends String,? extends Object> map)
javax.script.Bindings
Map
to this Bindings
.public Object remove(Object key)
javax.script.Bindings
(key==null ? k==null : key.equals(k))
, that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.
public boolean delete(Object key)
key
- the property to be deletedpublic int size()
java.util.Map
public Collection<Object> values()
JSObject
public Object getProto()
public void setProto(Object proto)
proto
- new proto for this objectpublic Object getOwnPropertyDescriptor(String key)
key
- property keypublic String[] getOwnKeys(boolean all)
all
- True if to include non-enumerable keys.public ScriptObjectMirror preventExtensions()
public boolean isExtensible()
public ScriptObjectMirror seal()
public boolean isSealed()
public ScriptObjectMirror freeze()
public boolean isFrozen()
public static boolean isUndefined(Object obj)
obj
- object to checkpublic <T> T to(Class<T> type)
T
- destination type to convert totype
- destination type to convert topublic static Object wrap(Object obj, Object homeGlobal)
obj
- object to be wrapped/convertedhomeGlobal
- global to which this object belongs.public static Object wrapAsJSONCompatible(Object obj, Object homeGlobal)
List
interface if obj
is a JavaScript Array
object;
this is compatible with Java JSON libraries expectations. Arrays retrieved through its
properties (transitively) will also implement the list interface.obj
- object to be wrapped/convertedhomeGlobal
- global to which this object belongs.public static Object unwrap(Object obj, Object homeGlobal)
obj
- object to be unwrappedhomeGlobal
- global to which this object belongspublic static Object[] wrapArray(Object[] args, Object homeGlobal)
args
- array to be unwrappedhomeGlobal
- global to which this object belongspublic static Object[] unwrapArray(Object[] args, Object homeGlobal)
args
- array to be unwrappedhomeGlobal
- global to which this object belongspublic static boolean identical(Object obj1, Object obj2)
obj1
- first objectobj2
- second object@Deprecated public double toNumber()
AbstractJSObject
toNumber
in interface JSObject
toNumber
in class AbstractJSObject
public Object getDefaultValue(Class<?> hint)
AbstractJSObject
[[DefaultValue]]
method. The default implementation follows ECMAScript 5.1
section 8.6.2 but subclasses are free to provide their own implementations.getDefaultValue
in class AbstractJSObject
hint
- the type hint. Should be either null
, Number.class
or String.class
.
Copyright © 2014, 2023, Oracle and/or its affiliates. All rights reserved.