ITextStorepublic class CopyOnWriteTextStore extends java.lang.Object implements ITextStore
ITextStore wrapper.
This implementation uses an unmodifiable text store for the initial content. Upon first modification attempt, the unmodifiable store is replaced with a modifiable instance which must be supplied in the constructor.
This class is not intended to be subclassed.
| Modifier and Type | Field | Description |
|---|---|---|
protected ITextStore |
fTextStore |
The underlying "real" text store
|
| Constructor | Description |
|---|---|
CopyOnWriteTextStore(ITextStore modifiableTextStore) |
Creates an empty text store.
|
| Modifier and Type | Method | Description |
|---|---|---|
char |
get(int offset) |
Returns the character at the specified offset.
|
java.lang.String |
get(int offset,
int length) |
Returns the text of the specified character range.
|
int |
getLength() |
Returns number of characters stored in this text store.
|
void |
replace(int offset,
int length,
java.lang.String text) |
Replaces the specified character range with the given text.
|
void |
set(java.lang.String text) |
Replace the content of the text store with the given text.
|
protected ITextStore fTextStore
public CopyOnWriteTextStore(ITextStore modifiableTextStore)
modifiableTextStore - a modifiable ITextStore instance,
may not be nullpublic char get(int offset)
ITextStoreget in interface ITextStoreoffset - the offset in this text storepublic java.lang.String get(int offset,
int length)
ITextStoreget in interface ITextStoreoffset - the offset of the rangelength - the length of the rangepublic int getLength()
ITextStoregetLength in interface ITextStorepublic void replace(int offset,
int length,
java.lang.String text)
ITextStorereplace(getLength(), 0, "some text") is a valid call and
appends text to the end of the text store.replace in interface ITextStoreoffset - the offset of the range to be replacedlength - the number of characters to be replacedtext - the substitution textpublic void set(java.lang.String text)
ITextStorereplace(0, getLength(), text.set in interface ITextStoretext - the new content of the text store