Package org.graalvm.polyglot.proxy
Interface ProxyObject
- All Superinterfaces:
Proxy
Interface to be implemented to mimic guest language objects that contain members.
- Since:
- 19.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProxyObjectCreates a proxy backed by aMap.Returns the value of the member.Returns an array of member keys.booleanReturnstrueif the proxy object contains a member with the given key, or elsefalse.voidSets the value associated with a member.default booleanremoveMember(String key) Removes a member key and its value.
-
Method Details
-
getMember
Returns the value of the member.- Throws:
UnsupportedOperationException- if the operation is unsupported- Since:
- 19.0
-
getMemberKeys
Object getMemberKeys()Returns an array of member keys. The returned array must be interpreted as having array elements using the semantics ofContext.asValue(Object)and taking host access into consideration. Otherwise, anIllegalStateExceptionis thrown. If one of the return values of the array is not aStringthen aClassCastExceptionis thrown. Examples for valid return values are:nullfor no member keysProxyArraythat returnsStringvalues for each array elementListwith exclusively String elements (HostAccessmust allowListAccess)String[](HostAccessmust allowArrayAccess)- A guest language object representing an array of strings.
getMemberKeys()method must returntrueforhasMember(String).- Since:
- 19.0
- See Also:
-
hasMember
Returnstrueif the proxy object contains a member with the given key, or elsefalse. While not required ever member key which returnstrueforhasMember(String)should be returned bygetMemberKeys()to allow guest members to list member keys.- Since:
- 19.0
- See Also:
-
putMember
Sets the value associated with a member. If the member does notexistthen a new member is defined. If the definition of new members is not supported then anUnsupportedOperationExceptionis thrown.- Throws:
UnsupportedOperationException- if the operation is unsupported- Since:
- 19.0
-
removeMember
Removes a member key and its value. If the removal of existing members is not supported then anUnsupportedOperationExceptionis thrown.- Returns:
truewhen the member was removed,falsewhen the member didn't exist.- Throws:
UnsupportedOperationException- if the operation is unsupported- Since:
- 19.0
-
fromMap
Creates a proxy backed by aMap. If the set values of the map are host values then the they will beunboxed.- Since:
- 19.0
-