Package net.carcdr.ycrdt
Interface YXmlFragment
- All Superinterfaces:
AutoCloseable
A collaborative XML fragment container that supports concurrent editing.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this fragment and releases resources.getChild(int index) Gets a child node at the specified index.getElement(int index) Gets a child element at the specified index.getElement(YTransaction txn, int index) Gets a child element at the specified index within a transaction.getNodeType(int index) Returns the type of the child node at the specified index.getNodeType(YTransaction txn, int index) Returns the type of the child node at the specified index within a transaction.getText(int index) Gets a child text node at the specified index.getText(YTransaction txn, int index) Gets a child text node at the specified index within a transaction.voidinsertElement(int index, String tag) Inserts a child element at the specified index.voidinsertElement(YTransaction txn, int index, String tag) Inserts a child element at the specified index within a transaction.voidinsertText(int index, String content) Inserts a child text node at the specified index.voidinsertText(YTransaction txn, int index, String content) Inserts a child text node at the specified index within a transaction.booleanisClosed()Checks if this fragment has been closed.intlength()Returns the number of child nodes.intlength(YTransaction txn) Returns the number of child nodes within a transaction.Registers an observer for changes to this fragment.voidremove(int index, int length) Removes child nodes at the specified range.voidremove(YTransaction txn, int index, int length) Removes child nodes at the specified range within a transaction.toString()Returns the XML representation of this fragment.Returns the XML representation of this fragment.toXmlString(YTransaction txn) Returns the XML representation of this fragment within a transaction.
-
Method Details
-
length
int length()Returns the number of child nodes.- Returns:
- the child count
-
length
Returns the number of child nodes within a transaction.- Parameters:
txn- the transaction- Returns:
- the child count
-
insertElement
Inserts a child element at the specified index.- Parameters:
index- the index to insert attag- the tag name of the new element
-
insertElement
Inserts a child element at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index to insert attag- the tag name of the new element
-
insertText
Inserts a child text node at the specified index.- Parameters:
index- the index to insert atcontent- the initial text content
-
insertText
Inserts a child text node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index to insert atcontent- the initial text content
-
remove
void remove(int index, int length) Removes child nodes at the specified range.- Parameters:
index- the start indexlength- the number of nodes to remove
-
remove
Removes child nodes at the specified range within a transaction.- Parameters:
txn- the transactionindex- the start indexlength- the number of nodes to remove
-
getNodeType
Returns the type of the child node at the specified index.- Parameters:
index- the index- Returns:
- the node type
-
getNodeType
Returns the type of the child node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the node type
-
getChild
Gets a child node at the specified index.- Parameters:
index- the index- Returns:
- the child node (YXmlElement or YXmlText)
-
getElement
Gets a child element at the specified index.- Parameters:
index- the index- Returns:
- the element
-
getElement
Gets a child element at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the element
-
getText
Gets a child text node at the specified index.- Parameters:
index- the index- Returns:
- the text node
-
getText
Gets a child text node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the text node
-
toXmlString
-
toXmlString
Returns the XML representation of this fragment within a transaction.- Parameters:
txn- the transaction- Returns:
- the XML string
-
toString
-
observe
Registers an observer for changes to this fragment.- Parameters:
observer- the observer to register- Returns:
- a subscription handle for unregistering
-
close
void close()Closes this fragment and releases resources.- Specified by:
closein interfaceAutoCloseable
-
isClosed
boolean isClosed()Checks if this fragment has been closed.- Returns:
- true if closed, false otherwise
-