Package net.carcdr.ycrdt
Interface YText
-
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.voidInserts text at the specified index.voidinsert(YTransaction txn, int index, String chunk) Inserts text 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.
-
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
-
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
-
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
-