Package aQute.bnd.properties
Class CopyOnWriteTextStore.StringTextStore
java.lang.Object
aQute.bnd.properties.CopyOnWriteTextStore.StringTextStore
- All Implemented Interfaces:
ITextStore
- Enclosing class:
- CopyOnWriteTextStore
An unmodifiable String based text store. It is not possible to modify the
content other than using
set(java.lang.String)
. Trying to replace(int, int, java.lang.String)
a text
range will throw an UnsupportedOperationException
.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty text store.StringTextStore
(String text) Create a text store with initial content. -
Method Summary
Modifier and TypeMethodDescriptionchar
get
(int offset) Returns the character at the specified offset.get
(int offset, int length) Returns the text of the specified character range.int
Returns number of characters stored in this text store.void
Replaces the specified character range with the given text.void
Replace the content of the text store with the given text.
-
Field Details
-
fText
Represents the content of this text store.
-
-
Constructor Details
-
StringTextStore
StringTextStore()Create an empty text store. -
StringTextStore
StringTextStore(String text) Create a text store with initial content.- Parameters:
text
- the initial content
-
-
Method Details
-
get
public char get(int offset) Description copied from interface:ITextStore
Returns the character at the specified offset.- Specified by:
get
in interfaceITextStore
- Parameters:
offset
- the offset in this text store- Returns:
- the character at this offset
-
get
Description copied from interface:ITextStore
Returns the text of the specified character range.- Specified by:
get
in 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:ITextStore
Returns number of characters stored in this text store.- Specified by:
getLength
in interfaceITextStore
- Returns:
- the number of characters stored in this text store
-
replace
Description copied from interface:ITextStore
Replaces 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:
replace
in interfaceITextStore
- Parameters:
offset
- the offset of the range to be replacedlength
- the number of characters to be replacedtext
- the substitution text
-
set
Description copied from interface:ITextStore
Replace the content of the text store with the given text. Convenience method forreplace(0, getLength(), text
.- Specified by:
set
in interfaceITextStore
- Parameters:
text
- the new content of the text store
-