Package io.keikai.doc.collab.types
Class YMap<T>
- java.lang.Object
-
- io.keikai.doc.collab.types.AbstractType<YMapEvent>
-
- io.keikai.doc.collab.types.YMap<T>
-
- All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<java.lang.String,Item>>
- Direct Known Subclasses:
YXmlHook
public class YMap<T> extends AbstractType<YMapEvent> implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,Item>>
A shared Map implementation.
-
-
Field Summary
-
Fields inherited from class io.keikai.doc.collab.types.AbstractType
_doc, _length, _map, _searchMarker
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcallObserver(Transaction transaction, java.util.Set<java.lang.String> parentSubs)Creates a YMapEvent and calls observers.voidclear()Removes all elements from this YMap.YMap<T>clone()Clone this YMap.YMap<T>copy()voiddelete(java.lang.String key)Remove a specified element from this YMap.java.util.Iterator<java.util.Map.Entry<java.lang.String,Item>>entries()Returns an Iterator of [key, value] pairsvoidforEach(YMapConsumer f)Executes a provided function on once on every key-value pair.Tget(java.lang.String key)Returns a specified element from this YMap.booleanhas(java.lang.String key)Returns a boolean indicating whether the specified key exists or not.voidintegrate(Doc y, Item item)Integrate this type into the Yjs instance.java.util.Iterator<java.util.Map.Entry<java.lang.String,Item>>iterator()Returns an Iterator of [key, value] pairs.java.util.Iterator<java.lang.String>keys()Returns the keys for each element in the YMap Type.static YMap<?>readYMap(UpdateDecoder decoder)Creates a YMap from the given decoder.<E> Eset(java.lang.String key, E value)Adds 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.java.util.Iterator<T>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, unobserveDeep
-
-
-
-
Method Detail
-
integrate
public void integrate(Doc y, Item item)
Integrate this type into the Yjs instance.- Overrides:
integratein classAbstractType<YMapEvent>- Parameters:
y- The Yjs instance.item- The item representing this YMap.
-
copy
public YMap<T> copy()
- Overrides:
copyin classAbstractType<YMapEvent>- Returns:
- A new copy of this YMap.
-
clone
public YMap<T> clone()
Clone this YMap.- Overrides:
clonein classAbstractType<YMapEvent>- Returns:
- A clone of this YMap.
-
callObserver
public void callObserver(Transaction transaction, java.util.Set<java.lang.String> parentSubs)
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
public java.util.Iterator<java.lang.String> keys()
Returns the keys for each element in the YMap Type.- Returns:
- An iterator over the keys.
-
values
public java.util.Iterator<T> values()
Returns the values for each element in the YMap Type.- Returns:
- An iterator over the values.
-
entries
public java.util.Iterator<java.util.Map.Entry<java.lang.String,Item>> entries()
Returns an Iterator of [key, value] pairs- Returns:
- An iterator over key-value pairs.
-
iterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,Item>> iterator()
Returns an Iterator of [key, value] pairs.- Specified by:
iteratorin interfacejava.lang.Iterable<T>- Returns:
- An iterator over key-value pairs.
-
forEach
public void forEach(YMapConsumer f)
Executes a provided function on once on every key-value pair.- Parameters:
f- A function to execute on every element of this YMap.
-
delete
public void delete(java.lang.String key)
Remove a specified element from this YMap.- Parameters:
key- The key of the element to remove.
-
set
public <E> E set(java.lang.String key, E value)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
public T get(java.lang.String key)
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
public boolean has(java.lang.String key)
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
public void write(UpdateEncoder encoder)
Write the type reference to the encoder.- Overrides:
writein classAbstractType<YMapEvent>- Parameters:
encoder- The encoder to write to.
-
readYMap
public static YMap<?> readYMap(UpdateDecoder decoder)
Creates a YMap from the given decoder.- Parameters:
decoder- The decoder to read from.- Returns:
- A new YMap instance.
-
-