Package net.carcdr.ycrdt
Interface YXmlElement
- All Superinterfaces:
AutoCloseable,YXmlNode
A collaborative XML element that supports concurrent editing.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.carcdr.ycrdt.YXmlNode
YXmlNode.NodeType -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of child nodes.intchildCount(YTransaction txn) Returns the number of child nodes within a transaction.voidclose()Closes this element and releases resources.getAttribute(String name) Gets an attribute value.getAttribute(YTransaction txn, String name) Gets an attribute value within a transaction.String[]Returns all attribute names.String[]Returns all attribute names within a transaction.getChild(int index) Gets a child node at the specified index.getChild(YTransaction txn, int index) Gets a child node at the specified index within a transaction.intReturns the index of this element within its parent.intReturns the index of this element within its parent, using a transaction.Returns the parent element or fragment.getParent(YTransaction txn) Returns the parent element or fragment within a transaction.getTag()Returns the tag name of this element.getTag(YTransaction txn) Returns the tag name of this element within a transaction.insertElement(int index, String tag) Inserts a child element at the specified index.insertElement(YTransaction txn, int index, String tag) Inserts a child element at the specified index within a transaction.insertText(int index) Inserts a child text node at the specified index.insertText(YTransaction txn, int index) Inserts a child text node at the specified index within a transaction.booleanisClosed()Checks if this element has been closed.Registers an observer for changes to this element.voidremoveAttribute(String name) Removes an attribute.voidremoveAttribute(YTransaction txn, String name) Removes an attribute within a transaction.voidremoveChild(int index) Removes a child node at the specified index.voidremoveChild(YTransaction txn, int index) Removes a child node at the specified index within a transaction.voidsetAttribute(String name, String value) Sets an attribute value.voidsetAttribute(YTransaction txn, String name, String value) Sets an attribute value within a transaction.toString()Returns the XML representation of this element.toString(YTransaction txn) Returns the XML representation of this element within a transaction.Methods inherited from interface net.carcdr.ycrdt.YXmlNode
asElement, asText, getNodeType
-
Method Details
-
getTag
-
getTag
Returns the tag name of this element within a transaction.- Parameters:
txn- the transaction- Returns:
- the tag name
-
getAttribute
-
getAttribute
Gets an attribute value within a transaction.- Parameters:
txn- the transactionname- the attribute name- Returns:
- the attribute value, or null if not present
-
setAttribute
-
setAttribute
Sets an attribute value within a transaction.- Parameters:
txn- the transactionname- the attribute namevalue- the attribute value
-
removeAttribute
-
removeAttribute
Removes an attribute within a transaction.- Parameters:
txn- the transactionname- the attribute name
-
getAttributeNames
-
getAttributeNames
Returns all attribute names within a transaction.- Parameters:
txn- the transaction- Returns:
- an array of attribute names
-
childCount
int childCount()Returns the number of child nodes.- Returns:
- the child count
-
childCount
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- Returns:
- 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- Returns:
- the new element
-
insertText
Inserts a child text node at the specified index.- Parameters:
index- the index to insert at- Returns:
- the new text node
-
insertText
Inserts a child text node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index to insert at- Returns:
- the new text node
-
getChild
Gets a child node at the specified index.- Parameters:
index- the index- Returns:
- the child node (YXmlElement or YXmlText)
-
getChild
Gets a child node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index- Returns:
- the child node (YXmlElement or YXmlText)
-
removeChild
void removeChild(int index) Removes a child node at the specified index.- Parameters:
index- the index
-
removeChild
Removes a child node at the specified index within a transaction.- Parameters:
txn- the transactionindex- the index
-
getParent
-
getParent
Returns the parent element or fragment within a transaction.- Parameters:
txn- the transaction- Returns:
- the parent, or null if none
-
getIndexInParent
int getIndexInParent()Returns the index of this element within its parent.- Returns:
- the index
-
getIndexInParent
Returns the index of this element within its parent, using a transaction.- Parameters:
txn- the transaction- Returns:
- the index
-
toString
-
toString
Returns the XML representation of this element within a transaction.- Parameters:
txn- the transaction- Returns:
- the XML string
-
observe
Registers an observer for changes to this element.- Parameters:
observer- the observer to register- Returns:
- a subscription handle for unregistering
-
close
void close()Closes this element and releases resources.- Specified by:
closein interfaceAutoCloseable
-
isClosed
boolean isClosed()Checks if this element has been closed.- Returns:
- true if closed, false otherwise
-