public class TextChangesStorage
extends java.lang.Object
TextChange objects assuming that they are applied to the same text.
Provides ability to automatic merging them if necessary.
Not thread-safe.| Constructor and Description |
|---|
TextChangesStorage() |
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(char [] originalData,
int index)
Allows to retrieve character for the given index assuming that it should be resolved against 'client text', i.e.
|
void |
clear() |
java.util.List<TextChangeImpl> |
getChanges() |
java.util.List<? extends TextChange> |
getChanges(int start,
int end)
Allows to ask the storage for the list of changes that have intersections with the target text range (identified by the given
arguments).
|
boolean |
isEmpty() |
int |
size() |
void |
store(TextChange change)
Store given change merging it with previously stored ones if necessary.
|
java.lang.CharSequence |
substring(char [] originalData,
int start,
int end)
Allows to build substring of the client text with its changes registered within the current storage.
|
java.lang.String |
toString() |
public java.util.List<TextChangeImpl> getChanges()
store(TextChange). Note that the changes offsets relate to initial
text and that returned list is sorted by start offset in ascending orderstore(TextChange)public java.util.List<? extends TextChange> getChanges(int start, int end)
start - target range start offset (inclusive)end - target range end offset (exclusive)public boolean isEmpty()
public void clear()
public int size()
public void store(TextChange change)
'client text'),
i.e. with all stored changes applied to it. Example:
'12345';'replace text at [2; 3) range with 'ABC'' is applied to it (stored at the current object).
End-users see the text '12ABC45' now;
'replace text at [1; 6) range with 'XY''. Change range is assumed to
be related to the text visible to end-user, not initial one ('12ABC45', not '12345').
I.e. the user will see text '1XY5' now;
change - change to storepublic char charAt(char [] originalData,
int index)
registered changes applied to it.
Example:
'01234'; 'insert text 'a' at index 1' and
'insert text 'bc' at index 3';
'client text' now is '0a12bc34';originalData - original text to which registered changes are appliedindex - target symbol index (is assumed to be 'client text' index)public java.lang.CharSequence substring(char [] originalData,
int start,
int end)
originalData - original text to which registered changes are appliedstart - target substring start offset (against the 'client text'; inclusive)end - target substring end offset (against the 'client text'; exclusive)public java.lang.String toString()
toString in class java.lang.Object