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)
Indicates whether some other object is "equal to" this one.
|
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 |
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()
Returns a hash code value for the object.
|
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 obj)
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)
Utilitity to convert this script object to the given type.
|
double |
toNumber()
Returns this object's numeric value.
|
String |
toString()
Returns a string representation of the object.
|
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.
|
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
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
public int hashCode()
java.lang.Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode
in interface Map<String,Object>
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
java.lang.Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public Object call(Object thiz, Object... args)
AbstractJSObject
call
in interface JSObject
call
in class AbstractJSObject
thiz
- 'this' object to be passed to the functionargs
- arguments to methodpublic Object newObject(Object... args)
AbstractJSObject
newObject
in interface JSObject
newObject
in class AbstractJSObject
args
- arguments to methodpublic Object eval(String s)
AbstractJSObject
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)
AbstractJSObject
getMember
in interface JSObject
getMember
in class AbstractJSObject
name
- of memberpublic Object getSlot(int index)
AbstractJSObject
getSlot
in interface JSObject
getSlot
in class AbstractJSObject
index
- index slot to retrievepublic boolean hasMember(String name)
AbstractJSObject
hasMember
in interface JSObject
hasMember
in class AbstractJSObject
name
- name of memberpublic boolean hasSlot(int slot)
AbstractJSObject
hasSlot
in interface JSObject
hasSlot
in class AbstractJSObject
slot
- index to checkpublic void removeMember(String name)
AbstractJSObject
removeMember
in interface JSObject
removeMember
in class AbstractJSObject
name
- name of the memberpublic void setMember(String name, Object value)
AbstractJSObject
setMember
in interface JSObject
setMember
in class AbstractJSObject
name
- name of the membervalue
- value of the memberpublic void setSlot(int index, Object value)
AbstractJSObject
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 obj)
AbstractJSObject
isInstance
in interface JSObject
isInstance
in class AbstractJSObject
obj
- instace to checkpublic String getClassName()
AbstractJSObject
getClassName
in interface JSObject
getClassName
in class AbstractJSObject
public boolean isFunction()
AbstractJSObject
isFunction
in interface JSObject
isFunction
in class AbstractJSObject
public boolean isStrictFunction()
AbstractJSObject
isStrictFunction
in interface JSObject
isStrictFunction
in class AbstractJSObject
public boolean isArray()
AbstractJSObject
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()
AbstractJSObject
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()
AbstractJSObject
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. Not used for ConsStrings.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 objectpublic double toNumber()
AbstractJSObject
toNumber
in interface JSObject
toNumber
in class AbstractJSObject
Copyright © 2014, 2015, Oracle and/or its affiliates. All rights reserved.