- java.lang.Object
-
- jdk.nashorn.api.scripting.AbstractJSObject
-
- jdk.nashorn.api.scripting.ScriptObjectMirror
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
callMember(String functionName, Object... args)
Call member functionboolean
delete(Object key)
Delete a property from this object.ScriptObjectMirror
freeze()
ECMA 15.2.39 - freeze implementation.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.static boolean
identical(Object obj1, Object obj2)
Are the given objects mirrors to same underlying object?boolean
isExtensible()
Check if this script object is extensibleboolean
isFrozen()
Check whether this script object is frozenboolean
isSealed()
Check whether this script object is sealedstatic boolean
isUndefined(Object obj)
Utility to check if given object is ECMAScript undefined valueScriptObjectMirror
preventExtensions()
Flag this script object as non extensibleScriptObjectMirror
seal()
ECMAScript 15.2.3.8 - seal implementationvoid
setIndexedPropertiesToExternalArrayData(ByteBuffer buf)
Nashorn extension: setIndexedPropertiesToExternalArrayData.void
setProto(Object proto)
Set the __proto__ of this object.<T> T
to(Class<T> type)
Utility to convert this script object to the given type.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.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.-
Methods declared in class jdk.nashorn.api.scripting.AbstractJSObject
call, eval, getDefaultValue, getMember, getSlot, hasMember, hasSlot, isArray, isFunction, isInstance, isStrictFunction, keySet, newObject, removeMember, setMember, setSlot, toNumber, values
-
Methods declared in interface jdk.nashorn.api.scripting.JSObject
getClassName, getDefaultValue, isInstanceOf
-
Methods declared in interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
callMember
public Object callMember(String functionName, Object... args)
Call member function- Parameters:
functionName
- function nameargs
- arguments- Returns:
- return value of function
-
setIndexedPropertiesToExternalArrayData
public void setIndexedPropertiesToExternalArrayData(ByteBuffer buf)
Nashorn extension: setIndexedPropertiesToExternalArrayData. set indexed properties be exposed from a given nio ByteBuffer.- Parameters:
buf
- external buffer - should be a nio ByteBuffer
-
delete
public boolean delete(Object key)
Delete a property from this object.- Parameters:
key
- the property to be deleted- Returns:
- if the delete was successful or not
-
getProto
public Object getProto()
Return the __proto__ of this object.- Returns:
- __proto__ object.
-
setProto
public void setProto(Object proto)
Set the __proto__ of this object.- Parameters:
proto
- new proto for this object
-
getOwnPropertyDescriptor
public Object getOwnPropertyDescriptor(String key)
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
public String[] getOwnKeys(boolean all)
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
public ScriptObjectMirror 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
public ScriptObjectMirror 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
public ScriptObjectMirror 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
public static boolean isUndefined(Object obj)
Utility to check if given object is ECMAScript undefined value- Parameters:
obj
- object to check- Returns:
- true if 'obj' is ECMAScript undefined value
-
to
public <T> T to(Class<T> type)
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
public static Object wrap(Object obj, Object homeGlobal)
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
public static Object wrapAsJSONCompatible(Object obj, Object homeGlobal)
Make a script object mirror on given object if needed. The created wrapper will implement the JavaList
interface ifobj
is a JavaScriptArray
object; 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
public static Object unwrap(Object obj, Object homeGlobal)
Unwrap a script object mirror if needed.- Parameters:
obj
- object to be unwrappedhomeGlobal
- global to which this object belongs- Returns:
- unwrapped object
-
wrapArray
public static Object[] wrapArray(Object[] args, Object homeGlobal)
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
public static Object[] unwrapArray(Object[] args, Object homeGlobal)
Unwrap an array of script object mirrors if needed.- Parameters:
args
- array to be unwrappedhomeGlobal
- global to which this object belongs- Returns:
- unwrapped array
-
-