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 ProxyObject
Creates a proxy backed by aMap
.Returns the value of the member.Returns an array of member keys.boolean
Returnstrue
if the proxy object contains a member with the given key, or elsefalse
.void
Sets the value associated with a member.default boolean
removeMember
(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, anIllegalStateException
is thrown. If one of the return values of the array is not aString
then aClassCastException
is thrown. Examples for valid return values are:null
for no member keysProxyArray
that returnsString
values for each array elementList
with exclusively String elements (HostAccess
must allowListAccess)String[]
(HostAccess
must allowArrayAccess)- A guest language object representing an array of strings.
getMemberKeys()
method must returntrue
forhasMember(String)
.- Since:
- 19.0
- See Also:
-
hasMember
Returnstrue
if the proxy object contains a member with the given key, or elsefalse
. While not required ever member key which returnstrue
forhasMember(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 notexist
then a new member is defined. If the definition of new members is not supported then anUnsupportedOperationException
is 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 anUnsupportedOperationException
is thrown.- Returns:
true
when the member was removed,false
when 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
-