Top Description Methods
org.graalvm.polyglot.proxy

public Interface ProxyHashMap

Additional top-level class in compilation unit: ProxyHashMapImpl.

extends Proxy
Known Direct Implementers
org.graalvm.polyglot.proxy.ProxyHashMapImpl
Imports
org.graalvm.polyglot.Context, .HostAccess.Builder, .Value, java.util.Iterator, .List, .Map, .Map.Entry, .NoSuchElementException

Interface to be implemented to mimic guest language hash maps.
Since
21.1
See Also
Proxy

Method Summary

Modifier and TypeMethod and Description
public static ProxyHashMap
from(Map<Object, Object> values)

Creates a proxy hash map backed by a Java Map.

public Object
getHashEntriesIterator()

Returns the hash entries iterator.

public long
getHashSize()

Returns the number of map entries.

public Object
getHashValue(Value key)

Returns the value for the specified key.

public boolean
hasHashEntry(Value key)

Returns true if the proxy object contains a mapping for the specified key, or else false.

public void
putHashEntry(Value key, Value value)

Associates the specified value with the specified key.

public default boolean

Returns:

true when the mapping was removed, false when the mapping didn't exist.
removeHashEntry
(Value key)

Removes the mapping for a given key.

Method Detail

fromback to summary
public static ProxyHashMap from(Map<Object, Object> values)

Creates a proxy hash map backed by a Java Map. The map keys are as Object unboxed. If the set values are host values then they will be unboxed.

Since
21.1
getHashEntriesIteratorback to summary
public Object getHashEntriesIterator()

Returns the hash entries iterator. The returned object must be interpreted as an iterator using the semantics of Context#asValue(Object) otherwise an IllegalStateException is thrown. The iterator elements must be interpreted as two elements array using the semantics of Context#asValue(Object).

Examples for valid return values are:

Examples for valid iterator elements are:

Since
21.1
See Also
ProxyIterator
getHashSizeback to summary
public long getHashSize()

Returns the number of map entries.

Since
21.1
getHashValueback to summary
public Object getHashValue(Value key)

Returns the value for the specified key.

Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
21.1
hasHashEntryback to summary
public boolean hasHashEntry(Value key)

Returns true if the proxy object contains a mapping for the specified key, or else false. Every key which returns true for hasHashEntry(Value) must be included in the iterator returned by getHashEntriesIterator() to allow guest language to enumerate map entries.

Since
21.1
See Also
getHashEntriesIterator()
putHashEntryback to summary
public void putHashEntry(Value key, Value value)

Associates the specified value with the specified key. If the mapping for the specified key does not exist then a new mapping is defined otherwise, an existing mapping is updated.

Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
21.1
removeHashEntryback to summary
public default boolean removeHashEntry(Value key)

Removes the mapping for a given key. If the removal of existing mappings is not supported then an UnsupportedOperationException is thrown.

Returns:boolean

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

Exceptions
UnsupportedOperationException:
if the operation is unsupported
Since
21.1