Package net.carcdr.ycrdt
Interface YMap
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all entries from the map.voidclear(YTransaction txn) Removes all entries from the map within a transaction.voidclose()Closes this map and releases resources.booleancontainsKey(String key) Checks if the map contains the specified key.booleancontainsKey(YTransaction txn, String key) Checks if the map contains the specified key within a transaction.Gets a subdocument for the specified key.getDoc(YTransaction txn, String key) Gets a subdocument for the specified key within a transaction.doubleGets a double value for the specified key.doublegetDouble(YTransaction txn, String key) Gets a double value for the specified key within a transaction.Gets a string value for the specified key.getString(YTransaction txn, String key) Gets a string value for the specified key within a transaction.booleanisClosed()Checks if this map has been closed.booleanisEmpty()Checks if the map is empty.String[]keys()Returns all keys in the map.String[]keys(YTransaction txn) Returns all keys in the map within a transaction.Registers an observer for changes to this map.voidRemoves the specified key from the map.voidremove(YTransaction txn, String key) Removes the specified key from the map within a transaction.voidSets a subdocument for the specified key.voidsetDoc(YTransaction txn, String key, YDoc subdoc) Sets a subdocument for the specified key within a transaction.voidSets a double value for the specified key.voidsetDouble(YTransaction txn, String key, double value) Sets a double value for the specified key within a transaction.voidSets a string value for the specified key.voidsetString(YTransaction txn, String key, String value) Sets a string value for the specified key within a transaction.intsize()Returns the number of entries in the map.intsize(YTransaction txn) Returns the number of entries in the map within a transaction.toJson()Returns a JSON representation of this map.toJson(YTransaction txn) Returns a JSON representation of this map within a transaction.
-
Method Details
-
size
int size()Returns the number of entries in the map.- Returns:
- the size
-
size
Returns the number of entries in the map within a transaction.- Parameters:
txn- the transaction- Returns:
- the size
-
isEmpty
boolean isEmpty()Checks if the map is empty.- Returns:
- true if empty, false otherwise
-
getString
-
getString
Gets a string value for the specified key within a transaction.- Parameters:
txn- the transactionkey- the key- Returns:
- the string value, or null if not present
-
setString
-
setString
Sets a string value for the specified key within a transaction.- Parameters:
txn- the transactionkey- the keyvalue- the value to set
-
getDouble
Gets a double value for the specified key.- Parameters:
key- the key- Returns:
- the double value
-
getDouble
Gets a double value for the specified key within a transaction.- Parameters:
txn- the transactionkey- the key- Returns:
- the double value
-
setDouble
Sets a double value for the specified key.- Parameters:
key- the keyvalue- the value to set
-
setDouble
Sets a double value for the specified key within a transaction.- Parameters:
txn- the transactionkey- the keyvalue- the value to set
-
getDoc
-
getDoc
Gets a subdocument for the specified key within a transaction.- Parameters:
txn- the transactionkey- the key- Returns:
- the subdocument, or null if not present
-
setDoc
-
setDoc
Sets a subdocument for the specified key within a transaction.- Parameters:
txn- the transactionkey- the keysubdoc- the subdocument to set
-
containsKey
Checks if the map contains the specified key.- Parameters:
key- the key- Returns:
- true if the key exists, false otherwise
-
containsKey
Checks if the map contains the specified key within a transaction.- Parameters:
txn- the transactionkey- the key- Returns:
- true if the key exists, false otherwise
-
keys
-
keys
Returns all keys in the map within a transaction.- Parameters:
txn- the transaction- Returns:
- an array of keys
-
remove
-
remove
Removes the specified key from the map within a transaction.- Parameters:
txn- the transactionkey- the key to remove
-
clear
void clear()Removes all entries from the map. -
clear
Removes all entries from the map within a transaction.- Parameters:
txn- the transaction
-
toJson
-
toJson
Returns a JSON representation of this map within a transaction.- Parameters:
txn- the transaction- Returns:
- the JSON string
-
observe
Registers an observer for changes to this map.- Parameters:
observer- the observer to register- Returns:
- a subscription handle for unregistering
-
close
-
isClosed
boolean isClosed()Checks if this map has been closed.- Returns:
- true if closed, false otherwise
-