public class CollaborativeString extends CollaborativeObject
Changes to the string will automatically be synced with the server and other collaborators. To listen for changes, add EventListeners for the following event types:
This class should not be instantiated directly. To create a new collaborative string, use
Model.createString(String)
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
__jsniRunAfter__() |
void |
addTextDeletedListener(EventHandler<TextDeletedEvent> handler) |
void |
addTextInsertedListener(EventHandler<TextInsertedEvent> handler) |
void |
append(String text)
Appends a string to the end of this one.
|
protected void |
consume(String userId,
String sessionId,
com.goodow.realtime.operation.Operation<?> operation) |
String |
getText()
Gets a string representation of the collaborative string.
|
void |
insertString(int index,
String text)
Inserts a string into the collaborative string at a specific index.
|
int |
length() |
IndexReference |
registerReference(int index,
boolean canBeDeleted)
Creates an IndexReference at the given
index. |
void |
removeRange(int startIndex,
int endIndex)
Deletes the text between startIndex (inclusive) and endIndex (exclusive).
|
void |
removeStringListener(EventHandler<?> handler) |
void |
setText(String text)
Sets the contents of this collaborative string.
|
addEventListener, addObjectChangedListener, getId, removeEventListener, removeObjectChangedListener, toString@GwtIncompatible(value="J2ObjC blocked by JSNI") public static void __jsniRunAfter__()
public void addTextDeletedListener(EventHandler<TextDeletedEvent> handler)
public void addTextInsertedListener(EventHandler<TextInsertedEvent> handler)
public void append(String text)
text - The new text to append.IllegalArgumentExceptionpublic String getText()
public void insertString(int index,
String text)
index - The index to insert at.text - The new text to insert.IllegalArgumentExceptionStringIndexOutOfBoundsExceptionpublic int length()
public IndexReference registerReference(int index, boolean canBeDeleted)
index. If canBeDeleted is set, then a
delete over the index will delete the reference. Otherwise the reference will shift to the
beginning of the deleted range.index - The index of the reference.canBeDeleted - Whether this index is deleted when there is a delete of a range covering
this index.public void removeRange(int startIndex,
int endIndex)
startIndex - The start index of the range to delete (inclusive).endIndex - The end index of the range to delete (exclusive).StringIndexOutOfBoundsExceptionpublic void removeStringListener(EventHandler<?> handler)
public void setText(String text)
text - The new value of the string.Copyright © 2013. All Rights Reserved.