Package io.keikai.doc.collab.types
Class YXmlFragment<T>
- java.lang.Object
-
- io.keikai.doc.collab.types.AbstractType<YXmlEvent>
-
- io.keikai.doc.collab.types.YXmlFragment<T>
-
- Direct Known Subclasses:
YXmlElement
public class YXmlFragment<T> extends AbstractType<YXmlEvent>
Represents a list ofYXmlElement.andYXmlTexttypes. A YxmlFragment is similar to aYXmlElement, but it does not have a nodeName, and it does not have attributes. Though it can be bound to a DOM element - in this case the attributes and the nodeName are not shared.
-
-
Field Summary
-
Fields inherited from class io.keikai.doc.collab.types.AbstractType
_doc, _length, _map, _searchMarker
-
-
Constructor Summary
Constructors Constructor Description YXmlFragment()
-
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 YXmlEvent and calls observers.YXmlFragmentclone()Makes a copy of this data type that can be included somewhere else.YXmlFragmentcopy()YXmlTreeWalkercreateTreeWalker(java.util.function.Function<AbstractType,java.lang.Boolean> filter)Create a subtree of childNodes.voiddelete(int index)Deletes elements starting from an index.voiddelete(int index, int length)Deletes elements starting from an index.voidforEach(TriConsumer<java.lang.Object,java.lang.Integer,AbstractType> f)Executes a provided function once on every child element.java.lang.Objectget(int index)Returns the i-th element from a YArray.AbstractTypegetFirstChild()voidinsert(int index, java.util.List<T> content)Inserts new content at an index.voidinsertAfter(java.lang.Object ref, java.util.List<T> content)Inserts new content after a reference element.voidintegrate(Doc y, Item item)Integrate this type into the Yjs instanceintlength()voidpush(java.util.List<T> content)Appends content to this YArray.AbstractTypequerySelector(java.lang.String query)Returns the first YXmlElement that matches the query.java.util.List<AbstractType>querySelectorAll(java.lang.String query)Returns all YXmlElements that match the query.static YXmlFragmentreadYXmlFragment(UpdateDecoder decoder)java.util.List<java.lang.Object>slice(int start, int end)Returns a portion of this YXmlFragment into a JavaScript Array selected from start to end (end not included).java.lang.Object[]toArray()Transforms this YArray to a Object Array.java.lang.StringtoJSON()Converts the type to a JSON object representation.java.util.List<java.lang.Object>toList()Transforms this YArray to a Object List.java.lang.StringtoString()Get the string representation of all the children of this YXmlFragment.voidunshift(java.util.List<T> content)Prepends content to this YArray.voidwrite(UpdateEncoder encoder)Transform the properties of this type to binary and write it to a BinaryEncoder.-
Methods inherited from class io.keikai.doc.collab.types.AbstractType
callTypeObservers, createMapIterator, getDeepEventHandler, getDoc, getFirst, getItem, getMap, getParent, getSearchMarker, getStart, getTypeChildren, isParentOf, 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
-
getFirstChild
public AbstractType getFirstChild()
- Returns:
- YXmlElement or YXmlText|null
-
integrate
public void integrate(Doc y, Item item)
Integrate this type into the Yjs instance. * Save this struct in the os * This type is sent to other clients * Observer functions are fired- Overrides:
integratein classAbstractType<YXmlEvent>- Parameters:
y- The Yjs instance.item- The item to integrate.
-
copy
public YXmlFragment copy()
- Overrides:
copyin classAbstractType<YXmlEvent>
-
clone
public YXmlFragment clone()
Makes a copy of this data type that can be included somewhere else. Note that the content is only readable _after_ it has been included somewhere in the Ydoc.- Overrides:
clonein classAbstractType<YXmlEvent>- Returns:
- YXmlFragment
-
length
public int length()
- Overrides:
lengthin classAbstractType<YXmlEvent>
-
createTreeWalker
public YXmlTreeWalker createTreeWalker(java.util.function.Function<AbstractType,java.lang.Boolean> filter)
Create a subtree of childNodes.- Parameters:
filter- Function that is called on each child element and returns a Boolean indicating whether the child is to be included in the subtree.- Returns:
- YXmlTreeWalker A subtree and a position within it.
-
querySelector
public AbstractType querySelector(java.lang.String query)
Returns the first YXmlElement that matches the query. Similar to DOM's querySelector.- Parameters:
query- The query on the children.- Returns:
- YXmlElement|YXmlText|YXmlHook|null The first element that matches the query or null.
-
querySelectorAll
public java.util.List<AbstractType> querySelectorAll(java.lang.String query)
Returns all YXmlElements that match the query. Similar to Dom's querySelectorAll.- Parameters:
query- The query on the children.- Returns:
- List of YXmlElement|YXmlText|YXmlHook|null. The elements that match this query.
-
callObserver
public void callObserver(Transaction transaction, java.util.Set<java.lang.String> parentSubs)
Creates YXmlEvent and calls observers.- Overrides:
callObserverin classAbstractType<YXmlEvent>- Parameters:
transaction- The transaction that occurred.parentSubs- Keys changed on this type. `null` if the list was modified.
-
toString
public java.lang.String toString()
Get the string representation of all the children of this YXmlFragment.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation of all children.
-
toJSON
public java.lang.String toJSON()
Description copied from class:AbstractTypeConverts the type to a JSON object representation.- Overrides:
toJSONin classAbstractType<YXmlEvent>- Returns:
- JSON representation of the fragment.
-
insert
public void insert(int index, java.util.List<T> content)Inserts new content at an index.- Parameters:
index- The index to insert content at.content- The array of content.
-
insertAfter
public void insertAfter(java.lang.Object ref, java.util.List<T> content)Inserts new content after a reference element.- Parameters:
ref- The index to insert content at.content- The array of content.
-
delete
public void delete(int index)
Deletes elements starting from an index.- Parameters:
index- Index at which to start deleting elements.
-
delete
public void delete(int index, int length)Deletes elements starting from an index.- Parameters:
index- Index at which to start deleting elements.length- The number of elements to remove. Defaults to 1.
-
toArray
public java.lang.Object[] toArray()
Transforms this YArray to a Object Array.- Returns:
- Array of YXmlElement, YXmlText, or YXmlHook.
-
toList
public java.util.List<java.lang.Object> toList()
Transforms this YArray to a Object List.- Returns:
- Array of YXmlElement, YXmlText, or YXmlHook.
-
push
public void push(java.util.List<T> content)
Appends content to this YArray.- Parameters:
content- Array of content to append.
-
unshift
public void unshift(java.util.List<T> content)
Prepends content to this YArray.- Parameters:
content- Array of content to prepend.
-
get
public java.lang.Object get(int index)
Returns the i-th element from a YArray.- Parameters:
index- The index of the element to return from the YArray.- Returns:
- YXmlElement or YXmlText.
-
slice
public java.util.List<java.lang.Object> slice(int start, int end)Returns a portion of this YXmlFragment into a JavaScript Array selected from start to end (end not included).- Parameters:
start- Starting index.end- Ending index (not included).- Returns:
- Array of YXmlElement or YXmlText.
-
forEach
public void forEach(TriConsumer<java.lang.Object,java.lang.Integer,AbstractType> f)
Executes a provided function once on every child element.- Parameters:
f- A function to execute on every element of this YArray.
-
write
public void write(UpdateEncoder encoder)
Transform the properties of this type to binary and write it to a BinaryEncoder. This is called when this Item is sent to a remote peer.- Overrides:
writein classAbstractType<YXmlEvent>- Parameters:
encoder- The encoder to write data to.
-
readYXmlFragment
public static YXmlFragment readYXmlFragment(UpdateDecoder decoder)
- Parameters:
decoder- The decoder to read data from.- Returns:
- YXmlFragment
-
-