Package net.carcdr.ycrdt
Interface YXmlText
- All Superinterfaces:
AutoCloseable,YXmlNode
A collaborative XML text node that supports concurrent editing with formatting.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.carcdr.ycrdt.YXmlNode
YXmlNode.NodeType -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this text and releases resources.voiddelete(int index, int length) Deletes text at the specified range.voiddelete(YTransaction txn, int index, int length) Deletes text at the specified range within a transaction.voidApplies formatting attributes to a range of text.voidformat(YTransaction txn, int index, int length, Map<String, Object> attributes) Applies formatting attributes to a range of text within a transaction.Returns the text content as formatting chunks.Returns the text content as formatting chunks within a transaction.intReturns the index of this node within its parent.intReturns the index of this node within its parent, using a transaction.Returns the parent element or fragment.getParent(YTransaction txn) Returns the parent element or fragment within a transaction.voidInserts text at the specified index.voidinsert(YTransaction txn, int index, String chunk) Inserts text at the specified index within a transaction.voidinsertWithAttributes(int index, String chunk, Map<String, Object> attributes) Inserts text with formatting attributes at the specified index.voidinsertWithAttributes(YTransaction txn, int index, String chunk, Map<String, Object> attributes) Inserts text with formatting attributes at the specified index within a transaction.booleanisClosed()Checks if this text has been closed.intlength()Returns the length of the text.intlength(YTransaction txn) Returns the length of the text within a transaction.Registers an observer for changes to this text.voidAppends text to the end.voidpush(YTransaction txn, String chunk) Appends text to the end within a transaction.toString()Returns the text content.toString(YTransaction txn) Returns the text content within a transaction.Methods inherited from interface net.carcdr.ycrdt.YXmlNode
asElement, asText, getNodeType
-
Method Details
-
length
int length()Returns the length of the text.- Returns:
- the number of characters
-
length
Returns the length of the text within a transaction.- Parameters:
txn- the transaction- Returns:
- the number of characters
-
toString
-
toString
Returns the text content within a transaction.- Parameters:
txn- the transaction- Returns:
- the text as a string
-
insert
Inserts text at the specified index.- Parameters:
index- the position to insert atchunk- the text to insert
-
insert
Inserts text at the specified index within a transaction.- Parameters:
txn- the transactionindex- the position to insert atchunk- the text to insert
-
push
-
push
Appends text to the end within a transaction.- Parameters:
txn- the transactionchunk- the text to append
-
delete
void delete(int index, int length) Deletes text at the specified range.- Parameters:
index- the start positionlength- the number of characters to delete
-
delete
Deletes text at the specified range within a transaction.- Parameters:
txn- the transactionindex- the start positionlength- the number of characters to delete
-
insertWithAttributes
-
insertWithAttributes
Inserts text with formatting attributes at the specified index within a transaction.- Parameters:
txn- the transactionindex- the position to insert atchunk- the text to insertattributes- the formatting attributes
-
format
-
format
Applies formatting attributes to a range of text within a transaction.- Parameters:
txn- the transactionindex- the start positionlength- the number of characters to formatattributes- the formatting attributes
-
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 node within its parent.- Returns:
- the index
-
getIndexInParent
Returns the index of this node within its parent, using a transaction.- Parameters:
txn- the transaction- Returns:
- the index
-
getFormattingChunks
List<FormattingChunk> getFormattingChunks()Returns the text content as formatting chunks.- Returns:
- a list of formatting chunks
-
getFormattingChunks
Returns the text content as formatting chunks within a transaction.- Parameters:
txn- the transaction- Returns:
- a list of formatting chunks
-
observe
Registers an observer for changes to this text.- Parameters:
observer- the observer to register- Returns:
- a subscription handle for unregistering
-
close
void close()Closes this text and releases resources.- Specified by:
closein interfaceAutoCloseable
-
isClosed
boolean isClosed()Checks if this text has been closed.- Returns:
- true if closed, false otherwise
-