private static class CopyOnWriteTextStore.StringTextStore extends java.lang.Object implements ITextStore
set(java.lang.String)
. Trying to replace(int, int, java.lang.String)
a text
range will throw an UnsupportedOperationException
.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
fText
Represents the content of this text store.
|
Constructor and Description |
---|
StringTextStore()
Create an empty text store.
|
StringTextStore(java.lang.String text)
Create a text store with initial content.
|
Modifier and Type | Method and 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.
|
StringTextStore()
StringTextStore(java.lang.String text)
text
- the initial contentpublic char get(int offset)
ITextStore
get
in interface ITextStore
offset
- the offset in this text storepublic java.lang.String get(int offset, int length)
ITextStore
get
in interface ITextStore
offset
- the offset of the rangelength
- the length of the rangepublic int getLength()
ITextStore
getLength
in interface ITextStore
public void replace(int offset, int length, java.lang.String text)
ITextStore
replace(getLength(), 0, "some text")
is a valid call and
appends text to the end of the text store.replace
in interface ITextStore
offset
- the offset of the range to be replacedlength
- the number of characters to be replacedtext
- the substitution textpublic void set(java.lang.String text)
ITextStore
replace(0, getLength(), text
.set
in interface ITextStore
text
- the new content of the text store