Interface BasicTextModel.Content
- All Known Implementing Classes:
BasicTextModel.InMemoryContent
- Enclosing class:
BasicTextModel
public static interface BasicTextModel.Content
This interface describes the underlying storage mechanism for the BasicTextModel.
- Since:
- 24
-
Method Summary
Modifier and TypeMethodDescriptiongetText(int index) Returns the text string for the specified paragraph index.voidinsertLineBreak(int index, int offset) Inserts a line break.intinsertTextSegment(int index, int offset, String text, StyleAttributeMap attrs) This method is called to insert a single text segment at the given position.booleanDetermines whether this content is writable (i.e.voidremoveRange(TextPos start, TextPos end) Removes the specified range.intsize()Returns the number of paragraphs in this content.
-
Method Details
-
size
int size()Returns the number of paragraphs in this content.- Returns:
- the number paragraphs
-
getText
Returns the text string for the specified paragraph index. The returned text string cannot be null and must not contain any control characters other than TAB. The caller should never attempt to ask for a paragraph outside of the valid range.- Parameters:
index- the paragraph index in the range (0...size())- Returns:
- the text string or null
-
insertTextSegment
This method is called to insert a single text segment at the given position. TheBasicTextModelguarantees that this method is only called when the content is writable.- Parameters:
index- the paragraph indexoffset- the insertion offset within the paragraphtext- the text to insertattrs- the style attributes- Returns:
- the number of characters inserted
-
insertLineBreak
void insertLineBreak(int index, int offset) Inserts a line break. TheBasicTextModelguarantees that this method is only called when the content is writable.- Parameters:
index- the model indexoffset- the text offset
-
removeRange
Removes the specified range. TheBasicTextModelguarantees that this method is only called when the content is writable, and thatstartprecedesend.- Parameters:
start- the start of the region to be removedend- the end of the region to be removed, expected to be greater than the start position
-
isWritable
boolean isWritable()Determines whether this content is writable (i.e. supports modification).- Returns:
- true if writable
-