Package org.graalvm.polyglot.proxy
Interface ProxyHashMap
- All Superinterfaces:
Proxy
Interface to be implemented to mimic guest language hash maps.
- Since:
- 21.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProxyHashMap
Creates a proxy hash map backed by a JavaMap
.Returns the hash entries iterator.long
Returns the number of map entries.getHashValue
(Value key) Returns the value for the specified key.boolean
hasHashEntry
(Value key) Returnstrue
if the proxy object contains a mapping for the specified key, or elsefalse
.void
putHashEntry
(Value key, Value value) Associates the specified value with the specified key.default boolean
removeHashEntry
(Value key) Removes the mapping for a given key.
-
Method Details
-
getHashSize
long getHashSize()Returns the number of map entries.- Since:
- 21.1
-
hasHashEntry
Returnstrue
if the proxy object contains a mapping for the specified key, or elsefalse
. Every key which returnstrue
forhasHashEntry(Value)
must be included in theiterator
returned bygetHashEntriesIterator()
to allow guest language to enumerate map entries.- Since:
- 21.1
- See Also:
-
getHashValue
Returns the value for the specified key.- Throws:
UnsupportedOperationException
- if the operation is unsupported- Since:
- 21.1
-
putHashEntry
Associates the specified value with the specified key. If the mapping for the specified key does notexist
then a new mapping is defined otherwise, an existing mapping is updated.- Throws:
UnsupportedOperationException
- if the operation is unsupported- Since:
- 21.1
-
removeHashEntry
Removes the mapping for a given key. If the removal of existing mappings is not supported then anUnsupportedOperationException
is thrown.- Returns:
true
when the mapping was removed,false
when the mapping didn't exist.- Throws:
UnsupportedOperationException
- if the operation is unsupported- Since:
- 21.1
-
getHashEntriesIterator
Object getHashEntriesIterator()Returns the hash entries iterator. The returned object must be interpreted as an iterator using the semantics ofContext.asValue(Object)
otherwise anIllegalStateException
is thrown. The iterator elements must be interpreted as two elements array using the semantics ofContext.asValue(Object)
.Examples for valid return values are:
ProxyIterator
Iterator
, requireshost iterable access
- A guest language object representing an iterator
Examples for valid iterator elements are:
ProxyArray
List
, requireshost list access
Object[2]
, requireshost array access
Map.Entry
, requireshost map access
- A guest language object representing an array
- Since:
- 21.1
- See Also:
-
from
Creates a proxy hash map backed by a JavaMap
. The map keys areas Object unboxed
. If the set values are host values then they will beunboxed
.- Since:
- 21.1
-