Package io.keikai.doc.collab.types
Class YMap<T>
- Direct Known Subclasses:
YXmlHook
A shared Map implementation.
-
Field Summary
Fields inherited from class io.keikai.doc.collab.types.AbstractType
_doc, _length, _map, _searchMarker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcallObserver(Transaction transaction, Set<String> parentSubs) Creates a YMapEvent and calls observers.voidclear()Removes all elements from this YMap.clone()Clone this YMap.copy()voidRemove a specified element from this YMap.entries()Returns an Iterator of [key, value] pairsvoidExecutes a provided function on once on every key-value pair.Returns a specified element from this YMap.booleanReturns a boolean indicating whether the specified key exists or not.voidIntegrate this type into the Yjs instance.iterator()Returns an Iterator of [key, value] pairs.keys()Returns the keys for each element in the YMap Type.static YMap<?>readYMap(UpdateDecoder decoder) Creates a YMap from the given decoder.<E> EAdds or updates an element with a specified key and value.intsize()Returns the size of the YMap (count of key/value pairs).org.zkoss.json.JSONObjecttoJSON()Transforms this Shared Type to a JSON object.values()Returns the values for each element in the YMap Type.voidwrite(UpdateEncoder encoder) Write the type reference to the encoder.Methods inherited from class io.keikai.doc.collab.types.AbstractType
callTypeObservers, createMapIterator, getDeepEventHandler, getDoc, getFirst, getItem, getMap, getParent, getSearchMarker, getStart, getTypeChildren, isParentOf, length, observe, observe, observeDeep, setLength, setMap, setStart, typeListCreateIterator, typeListDelete, typeListForEach, typeListForEachSnapshot, typeListGet, typeListInsertGenerics, typeListInsertGenericsAfter, typeListMap, typeListPushGenerics, typeListSlice, typeListToArray, typeListToArraySnapshot, typeMapDelete, typeMapGet, typeMapGetAll, typeMapGetAllSnapshot, typeMapGetSnapshot, typeMapHas, typeMapSet, unobserve, unobserveDeepMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
YMap
public YMap()Constructor to create an empty YMap. -
YMap
Constructor to create a YMap with initial entries.- Parameters:
entries- An iterable of entries to initialize the YMap.
-
-
Method Details
-
integrate
Integrate this type into the Yjs instance.- Overrides:
integratein classAbstractType<YMapEvent>- Parameters:
y- The Yjs instance.item- The item representing this YMap.
-
copy
- Overrides:
copyin classAbstractType<YMapEvent>- Returns:
- A new copy of this YMap.
-
clone
Clone this YMap.- Overrides:
clonein classAbstractType<YMapEvent>- Returns:
- A clone of this YMap.
-
callObserver
Creates a YMapEvent and calls observers.- Overrides:
callObserverin classAbstractType<YMapEvent>- Parameters:
transaction- The transaction in which the change occurred.parentSubs- Keys changed on this type. `null` if list was modified.
-
toJSON
public org.zkoss.json.JSONObject toJSON()Transforms this Shared Type to a JSON object.- Overrides:
toJSONin classAbstractType<YMapEvent>- Returns:
- A JSON representation of this YMap.
-
size
public int size()Returns the size of the YMap (count of key/value pairs).- Returns:
- The size of the YMap.
-
keys
Returns the keys for each element in the YMap Type.- Returns:
- An iterator over the keys.
-
values
Returns the values for each element in the YMap Type.- Returns:
- An iterator over the values.
-
entries
Returns an Iterator of [key, value] pairs- Returns:
- An iterator over key-value pairs.
-
iterator
Returns an Iterator of [key, value] pairs. -
forEach
Executes a provided function on once on every key-value pair.- Parameters:
f- A function to execute on every element of this YMap.
-
delete
Remove a specified element from this YMap.- Parameters:
key- The key of the element to remove.
-
set
Adds or updates an element with a specified key and value.- Parameters:
key- The key of the element to add to this YMap.value- The value of the element to add.- Returns:
- The added value.
-
get
Returns a specified element from this YMap.- Parameters:
key- The key of the element to retrieve.- Returns:
- The value associated with the key, or null if not found.
-
has
Returns a boolean indicating whether the specified key exists or not.- Parameters:
key- The key to test.- Returns:
- True if the key exists, false otherwise.
-
clear
public void clear()Removes all elements from this YMap. -
write
Write the type reference to the encoder.- Overrides:
writein classAbstractType<YMapEvent>- Parameters:
encoder- The encoder to write to.
-
readYMap
Creates a YMap from the given decoder.- Parameters:
decoder- The decoder to read from.- Returns:
- A new YMap instance.
-