java.lang.Object
org.openjdk.nashorn.api.scripting.AbstractJSObject
org.openjdk.nashorn.api.scripting.ScriptObjectMirror
Mirror object that wraps a given Nashorn Script object.
- Since:
- 1.8u40
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionCall this object as a JavaScript function.callMember(String functionName, Object... args) Call member functionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) booleanDelete a property from this object.entrySet()booleanEvaluate a JavaScript expression.freeze()ECMA 15.2.39 - freeze implementation.ECMA [[Class]] propertygetDefaultValue(Class<?> hint) Implements this object's[[DefaultValue]]method as per ECMAScript 5.1 section 8.6.2.Retrieves a named member of this JavaScript object.String[]getOwnKeys(boolean all) return an array of own property keys associated with the object.ECMA 8.12.1 [[GetOwnProperty]] (P)getProto()Return the __proto__ of this object.getSlot(int index) Retrieves an indexed member of this JavaScript object.inthashCode()booleanDoes this object have a named member?booleanhasSlot(int slot) Does this object have a indexed property?static booleanAre the given objects mirrors to same underlying object?booleanisArray()Is this an array object?booleanisEmpty()booleanCheck if this script object is extensiblebooleanisFrozen()Check whether this script object is frozenbooleanIs this a function object?booleanisInstance(Object instance) Checking whether the given object is an instance of 'this' object.booleanisSealed()Check whether this script object is sealedbooleanIs this a 'use strict' function object?static booleanisUndefined(Object obj) Utility to check if given object is ECMAScript undefined valuekeySet()Returns the set of all property names of this object.Call this 'constructor' JavaScript function to create a new object.Flag this script object as non extensiblevoidvoidremoveMember(String name) Remove a named member from this JavaScript objectseal()ECMAScript 15.2.3.8 - seal implementationvoidNashorn extension: setIndexedPropertiesToExternalArrayData.voidSet a named member in this JavaScript objectvoidSet the __proto__ of this object.voidSet an indexed member in this JavaScript objectintsize()<T> TUtility to convert this script object to the given type.doubletoNumber()Deprecated.toString()static ObjectUnwrap a script object mirror if needed.static Object[]unwrapArray(Object[] args, Object homeGlobal) Unwrap an array of script object mirrors if needed.values()Returns the set of all property values of this object.static ObjectMake a script object mirror on given object if needed.static Object[]Wrap an array of object to script object mirrors if needed.static ObjectwrapAsJSONCompatible(Object obj, Object homeGlobal) Make a script object mirror on given object if needed.Methods inherited from class org.openjdk.nashorn.api.scripting.AbstractJSObject
getDefaultValue, isInstanceOfMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
call
Description copied from interface:JSObjectCall this object as a JavaScript function. This is equivalent to 'func.apply(thiz, args)' in JavaScript.- Specified by:
callin interfaceJSObject- Overrides:
callin classAbstractJSObject- Parameters:
thiz- 'this' object to be passed to the function. This may be null.args- arguments to method- Returns:
- result of call
-
newObject
Description copied from interface:JSObjectCall this 'constructor' JavaScript function to create a new object. This is equivalent to 'new func(arg1, arg2...)' in JavaScript.- Specified by:
newObjectin interfaceJSObject- Overrides:
newObjectin classAbstractJSObject- Parameters:
args- arguments to method- Returns:
- result of constructor call
-
eval
Description copied from interface:JSObjectEvaluate a JavaScript expression.- Specified by:
evalin interfaceJSObject- Overrides:
evalin classAbstractJSObject- Parameters:
s- JavaScript expression to evaluate- Returns:
- evaluation result
-
callMember
Call member function- Parameters:
functionName- function nameargs- arguments- Returns:
- return value of function
-
getMember
Description copied from interface:JSObjectRetrieves a named member of this JavaScript object.- Specified by:
getMemberin interfaceJSObject- Overrides:
getMemberin classAbstractJSObject- Parameters:
name- of member- Returns:
- member
-
getSlot
Description copied from interface:JSObjectRetrieves an indexed member of this JavaScript object.- Specified by:
getSlotin interfaceJSObject- Overrides:
getSlotin classAbstractJSObject- Parameters:
index- index slot to retrieve- Returns:
- member
-
hasMember
Description copied from interface:JSObjectDoes this object have a named member?- Specified by:
hasMemberin interfaceJSObject- Overrides:
hasMemberin classAbstractJSObject- 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:JSObjectDoes this object have a indexed property?- Specified by:
hasSlotin interfaceJSObject- Overrides:
hasSlotin classAbstractJSObject- Parameters:
slot- index to check- Returns:
- true if this object has a slot
-
removeMember
Description copied from interface:JSObjectRemove a named member from this JavaScript object- Specified by:
removeMemberin interfaceJSObject- Overrides:
removeMemberin classAbstractJSObject- Parameters:
name- name of the member
-
setMember
Description copied from interface:JSObjectSet a named member in this JavaScript object- Specified by:
setMemberin interfaceJSObject- Overrides:
setMemberin classAbstractJSObject- Parameters:
name- name of the membervalue- value of the member
-
setSlot
Description copied from interface:JSObjectSet an indexed member in this JavaScript object- Specified by:
setSlotin interfaceJSObject- Overrides:
setSlotin classAbstractJSObject- Parameters:
index- index of the member slotvalue- value of the member
-
setIndexedPropertiesToExternalArrayData
Nashorn extension: setIndexedPropertiesToExternalArrayData. set indexed properties be exposed from a given nio ByteBuffer.- Parameters:
buf- external buffer - should be a nio ByteBuffer
-
isInstance
Description copied from interface:JSObjectChecking whether the given object is an instance of 'this' object.- Specified by:
isInstancein interfaceJSObject- Overrides:
isInstancein classAbstractJSObject- Parameters:
instance- instance to check- Returns:
- true if the given 'instance' is an instance of this 'function' object
-
getClassName
Description copied from interface:JSObjectECMA [[Class]] property- Specified by:
getClassNamein interfaceJSObject- Overrides:
getClassNamein classAbstractJSObject- Returns:
- ECMA [[Class]] property value of this object
-
isFunction
public boolean isFunction()Description copied from interface:JSObjectIs this a function object?- Specified by:
isFunctionin interfaceJSObject- Overrides:
isFunctionin classAbstractJSObject- Returns:
- if this mirror wraps a ECMAScript function instance
-
isStrictFunction
public boolean isStrictFunction()Description copied from interface:JSObjectIs this a 'use strict' function object?- Specified by:
isStrictFunctionin interfaceJSObject- Overrides:
isStrictFunctionin classAbstractJSObject- Returns:
- true if this mirror represents a ECMAScript 'use strict' function
-
isArray
public boolean isArray()Description copied from interface:JSObjectIs this an array object?- Specified by:
isArrayin interfaceJSObject- Overrides:
isArrayin classAbstractJSObject- Returns:
- if this mirror wraps a ECMAScript array object
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceBindings- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
Description copied from interface:JSObjectReturns the set of all property names of this object. -
put
-
putAll
-
remove
-
delete
Delete a property from this object.- Parameters:
key- the property to be deleted- Returns:
- if the delete was successful or not
-
size
public int size() -
values
Description copied from interface:JSObjectReturns the set of all property values of this object. -
getProto
Return the __proto__ of this object.- Returns:
- __proto__ object.
-
setProto
Set the __proto__ of this object.- Parameters:
proto- new proto for this object
-
getOwnPropertyDescriptor
ECMA 8.12.1 [[GetOwnProperty]] (P)- Parameters:
key- property key- Returns:
- Returns the Property Descriptor of the named own property of this object, or undefined if absent.
-
getOwnKeys
return an array of own property keys associated with the object.- Parameters:
all- True if to include non-enumerable keys.- Returns:
- Array of keys.
-
preventExtensions
Flag this script object as non extensible- Returns:
- the object after being made non extensible
-
isExtensible
public boolean isExtensible()Check if this script object is extensible- Returns:
- true if extensible
-
seal
ECMAScript 15.2.3.8 - seal implementation- Returns:
- the sealed script object
-
isSealed
public boolean isSealed()Check whether this script object is sealed- Returns:
- true if sealed
-
freeze
ECMA 15.2.39 - freeze implementation. Freeze this script object- Returns:
- the frozen script object
-
isFrozen
public boolean isFrozen()Check whether this script object is frozen- Returns:
- true if frozen
-
isUndefined
Utility to check if given object is ECMAScript undefined value- Parameters:
obj- object to check- Returns:
- true if 'obj' is ECMAScript undefined value
-
to
Utility to convert this script object to the given type.- Type Parameters:
T- destination type to convert to- Parameters:
type- destination type to convert to- Returns:
- converted object
-
wrap
Make a script object mirror on given object if needed.- Parameters:
obj- object to be wrapped/convertedhomeGlobal- global to which this object belongs.- Returns:
- wrapped/converted object
-
wrapAsJSONCompatible
Make a script object mirror on given object if needed. The created wrapper will implement the JavaListinterface ifobjis a JavaScriptArrayobject; this is compatible with Java JSON libraries expectations. Arrays retrieved through its properties (transitively) will also implement the list interface.- Parameters:
obj- object to be wrapped/convertedhomeGlobal- global to which this object belongs.- Returns:
- wrapped/converted object
-
unwrap
Unwrap a script object mirror if needed.- Parameters:
obj- object to be unwrappedhomeGlobal- global to which this object belongs- Returns:
- unwrapped object
-
wrapArray
Wrap an array of object to script object mirrors if needed.- Parameters:
args- array to be unwrappedhomeGlobal- global to which this object belongs- Returns:
- wrapped array
-
unwrapArray
Unwrap an array of script object mirrors if needed.- Parameters:
args- array to be unwrappedhomeGlobal- global to which this object belongs- Returns:
- unwrapped array
-
identical
Are the given objects mirrors to same underlying object?- Parameters:
obj1- first objectobj2- second object- Returns:
- true if obj1 and obj2 are identical script objects or mirrors of it.
-
toNumber
Deprecated.Description copied from class:AbstractJSObjectReturns this object's numeric value.- Specified by:
toNumberin interfaceJSObject- Overrides:
toNumberin classAbstractJSObject- Returns:
- this object's numeric value.
-
getDefaultValue
Description copied from interface:JSObjectImplements this object's[[DefaultValue]]method as per ECMAScript 5.1 section 8.6.2.- Specified by:
getDefaultValuein interfaceJSObject- Parameters:
hint- the type hint. Should be eithernull,Number.classorString.class.- Returns:
- this object's default value.
-