public class BulkChangesMerger
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static BulkChangesMerger |
INSTANCE |
| Constructor and Description |
|---|
BulkChangesMerger() |
| Modifier and Type | Method and Description |
|---|---|
void |
mergeInPlace(char [] data,
int length,
java.util.List<? extends TextChangeImpl> changes)
Allows to perform 'in-place' merge of the given changes to the given array.
|
char [] |
mergeToCharArray(char [] text,
int textLength,
java.util.List<? extends TextChange> changes)
Merges given changes within the given text and returns result as a new char array.
|
java.lang.CharSequence |
mergeToCharSequence(char [] text,
int textLength,
java.util.List<? extends TextChange> changes)
Merges given changes within the given text and returns result as a new char sequence.
|
int |
updateOffset(int originalOffset,
java.util.List<? extends TextChange> changes)
Given an offset of some location in the document, returns offset of this location after application of given changes.
|
public static final BulkChangesMerger INSTANCE
public java.lang.CharSequence mergeToCharSequence(char [] text,
int textLength,
java.util.List<? extends TextChange> changes)
text - text to apply given changes fortextLength - interested number of symbols from the given text to usechanges - changes to apply to the given text. It's assumed that there are no intersections between them and that they
are sorted by offsets in ascending orderpublic char [] mergeToCharArray(char [] text,
int textLength,
java.util.List<? extends TextChange> changes)
text - text to apply given changes fortextLength - interested number of symbols from the given text to usechanges - changes to apply to the given text. It's assumed that there are no intersections between them and that they
are sorted by offsets in ascending orderpublic void mergeInPlace(char [] data,
int length,
java.util.List<? extends TextChangeImpl> changes)
throws java.lang.IllegalArgumentException
[0; length) region and given changes define
offsets against it. It's also assumed that given array length is enough to contain resulting text after applying the changes.
Example: consider that initial text is '12345' and given changes are 'remove text at [1; 3) interval'
and 'replace text at [4; 5) interval with 'abcde''. Resulting text is '14abcde' then and given array
length should be not less than 7.data - data arraylength - initial text length (without changes)changes - change to apply to the target textjava.lang.IllegalArgumentException - if given array is not big enough to contain the resulting textpublic int updateOffset(int originalOffset,
java.util.List<? extends TextChange> changes)
mergeToCharSequence(char[], int, List) method.