Top Description Methods
org.graalvm.polyglot.proxy

public Interface ProxyObject

extends Proxy
Imports
java.util.List, .Map, org.graalvm.polyglot.Context, .Value, .HostAccess

Interface to be implemented to mimic guest language objects that contain members.
Since
19.0
See Also
Proxy

Method Summary

Modifier and TypeMethod and Description
public static ProxyObject
fromMap(Map<String, Object> values)

Creates a proxy backed by a Map.

public Object
getMember(String key)

Returns the value of the member.

public Object
getMemberKeys()

Returns an array of member keys.

public boolean
hasMember(String key)

Returns true if the proxy object contains a member with the given key, or else false.

public void
putMember(String key, Value value)

Sets the value associated with a member.

public default boolean

Returns:

true when the member was removed, false when the member didn't exist.
removeMember
(String key)

Removes a member key and its value.

Method Detail

fromMapback to summary
public static ProxyObject fromMap(Map<String, Object> values)

Creates a proxy backed by a Map. If the set values of the map are host values then the they will be unboxed.

Since
19.0
getMemberback to summary
public Object getMember(String key)

Returns the value of the member.

Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
19.0
getMemberKeysback to summary
public Object getMemberKeys()

Returns an array of member keys. The returned array must be interpreted as having array elements using the semantics of Context#asValue(Object) and taking host access into consideration. Otherwise, an IllegalStateException is thrown. If one of the return values of the array is not a String then a ClassCastException is thrown. Examples for valid return values are:

  • null for no member keys
  • ProxyArray that returns String values for each array element
  • List with exclusively String elements (HostAccess must allowListAccess)
  • String[] (HostAccess must allowArrayAccess)
  • A guest language object representing an array of strings.
Every member key returned by the getMemberKeys() method must return true for hasMember(String).
Since
19.0
See Also
hasMember(String), Context#asValue(Object)
hasMemberback to summary
public boolean hasMember(String key)

Returns true if the proxy object contains a member with the given key, or else false. While not required ever member key which returns true for hasMember(String) should be returned by getMemberKeys() to allow guest members to list member keys.

Since
19.0
See Also
getMemberKeys()
putMemberback to summary
public void putMember(String key, Value value)

Sets the value associated with a member. If the member does not exist then a new member is defined. If the definition of new members is not supported then an UnsupportedOperationException is thrown.

Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
19.0
removeMemberback to summary
public default boolean removeMember(String key)

Removes a member key and its value. If the removal of existing members is not supported then an UnsupportedOperationException is thrown.

Returns:boolean

true when the member was removed, false when the member didn't exist.

Annotations
@SuppressWarnings:unused
Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
19.0