AbstractDocument.Content (Java SE 15 & JDK 15) (original) (raw)
All Known Implementing Classes:
[GapContent](GapContent.html "class in javax.swing.text")
, [StringContent](StringContent.html "class in javax.swing.text")
Enclosing class:
public static interface AbstractDocument.Content
Interface to describe a sequence of character content that can be edited. Implementations may or may not support a history mechanism which will be reflected by whether or not mutations return an UndoableEdit implementation.
See Also:
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Position | createPosition(int offset) | Creates a position within the content that will track change as the content is mutated. |
void | getChars(int where, int len,Segment txt) | Gets a sequence of characters and copies them into a Segment. |
String | getString(int where, int len) | Fetches a string of characters contained in the sequence. |
UndoableEdit | insertString(int where,String str) | Inserts a string of characters into the sequence. |
int | length() | Current length of the sequence of character content. |
UndoableEdit | remove(int where, int nitems) | Removes some portion of the sequence. |
Method Details
createPosition
Creates a position within the content that will track change as the content is mutated.
Parameters:
offset
- the offset in the content >= 0
Returns:
a Position
Throws:
[BadLocationException](BadLocationException.html "class in javax.swing.text")
- for an invalid offsetlength
int length()
Current length of the sequence of character content.
Returns:
the length >= 0insertString
Inserts a string of characters into the sequence.
Parameters:
where
- offset into the sequence to make the insertion >= 0
str
- string to insert
Returns:
if the implementation supports a history mechanism, a reference to anEdit
implementation will be returned, otherwise returnsnull
Throws:
[BadLocationException](BadLocationException.html "class in javax.swing.text")
- thrown if the area covered by the arguments is not contained in the character sequenceremove
Removes some portion of the sequence.
Parameters:
where
- The offset into the sequence to make the insertion >= 0.
nitems
- The number of items in the sequence to remove >= 0.
Returns:
If the implementation supports a history mechanism, a reference to an Edit implementation will be returned, otherwise null.
Throws:
[BadLocationException](BadLocationException.html "class in javax.swing.text")
- Thrown if the area covered by the arguments is not contained in the character sequence.getString
Fetches a string of characters contained in the sequence.
Parameters:
where
- Offset into the sequence to fetch >= 0.
len
- number of characters to copy >= 0.
Returns:
the string
Throws:
[BadLocationException](BadLocationException.html "class in javax.swing.text")
- Thrown if the area covered by the arguments is not contained in the character sequence.getChars
Gets a sequence of characters and copies them into a Segment.
Parameters:
where
- the starting offset >= 0
len
- the number of characters >= 0
txt
- the target location to copy into
Throws:
[BadLocationException](BadLocationException.html "class in javax.swing.text")
- Thrown if the area covered by the arguments is not contained in the character sequence.