Package org.eclipse.jface.text
Class CopyOnWriteTextStore
- java.lang.Object
-
- org.eclipse.jface.text.CopyOnWriteTextStore
-
- All Implemented Interfaces:
ITextStore
public class CopyOnWriteTextStore extends Object implements ITextStore
Copy-on-writeITextStorewrapper.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.
- Since:
- 3.2
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected ITextStorefTextStoreThe underlying "real" text store
-
Constructor Summary
Constructors Constructor Description CopyOnWriteTextStore(ITextStore modifiableTextStore)Creates an empty text store.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charget(int offset)Returns the character at the specified offset.Stringget(int offset, int length)Returns the text of the specified character range.intgetLength()Returns number of characters stored in this text store.voidreplace(int offset, int length, String text)Replaces the specified character range with the given text.voidset(String text)Replace the content of the text store with the given text.
-
-
-
Field Detail
-
fTextStore
protected ITextStore fTextStore
The underlying "real" text store
-
-
Constructor Detail
-
CopyOnWriteTextStore
public CopyOnWriteTextStore(ITextStore modifiableTextStore)
Creates an empty text store. The given text store will be used upon first modification attempt.- Parameters:
modifiableTextStore- a modifiableITextStoreinstance, may not benull
-
-
Method Detail
-
get
public char get(int offset)
Description copied from interface:ITextStoreReturns the character at the specified offset.- Specified by:
getin interfaceITextStore- Parameters:
offset- the offset in this text store- Returns:
- the character at this offset
-
get
public String get(int offset, int length)
Description copied from interface:ITextStoreReturns the text of the specified character range.- Specified by:
getin interfaceITextStore- Parameters:
offset- the offset of the rangelength- the length of the range- Returns:
- the text of the range
-
getLength
public int getLength()
Description copied from interface:ITextStoreReturns number of characters stored in this text store.- Specified by:
getLengthin interfaceITextStore- Returns:
- the number of characters stored in this text store
-
replace
public void replace(int offset, int length, String text)Description copied from interface:ITextStoreReplaces the specified character range with the given text.replace(getLength(), 0, "some text")is a valid call and appends text to the end of the text store.- Specified by:
replacein interfaceITextStore- Parameters:
offset- the offset of the range to be replacedlength- the number of characters to be replacedtext- the substitution text
-
set
public void set(String text)
Description copied from interface:ITextStoreReplace the content of the text store with the given text. Convenience method forreplace(0, getLength(), text.- Specified by:
setin interfaceITextStore- Parameters:
text- the new content of the text store
-
-