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 ProxyHashMapCreates a proxy hash map backed by a JavaMap.Returns the hash entries iterator.longReturns the number of map entries.getHashValue(Value key) Returns the value for the specified key.booleanhasHashEntry(Value key) Returnstrueif the proxy object contains a mapping for the specified key, or elsefalse.voidputHashEntry(Value key, Value value) Associates the specified value with the specified key.default booleanremoveHashEntry(Value key) Removes the mapping for a given key.
-
Method Details
-
getHashSize
long getHashSize()Returns the number of map entries.- Since:
- 21.1
-
hasHashEntry
Returnstrueif the proxy object contains a mapping for the specified key, or elsefalse. Every key which returnstrueforhasHashEntry(Value)must be included in theiteratorreturned 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 notexistthen 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 anUnsupportedOperationExceptionis thrown.- Returns:
truewhen the mapping was removed,falsewhen 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 anIllegalStateExceptionis thrown. The iterator elements must be interpreted as two elements array using the semantics ofContext.asValue(Object).Examples for valid return values are:
ProxyIteratorIterator, requireshost iterable access- A guest language object representing an iterator
Examples for valid iterator elements are:
ProxyArrayList, requireshost list accessObject[2], requireshost array accessMap.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
-