public static final class TypedTextInterceptor.MutableContext extends TypedTextInterceptor.Context
Context
.Modifier and Type | Method and Description |
---|---|
String |
getReplacedText()
Gets the replaced text.
|
String |
getText()
Gets the insertion text.
|
void |
setText(String text,
int caretPosition)
Sets the insertion text and adjusted caret position.
|
void |
setText(String text,
int caretPosition,
boolean formatNewLines)
Sets the insertion text and adjusted caret position.
|
getComponent, getDocument, getOffset
public String getText()
TypedTextInterceptor.Context
It is guaranteed that the text will have length equal to 1 for contexts
that are passed to beforeInsert
and insert
methods. In these methods getText
returns exactly what
a user typed in the editor.
In the afterInsert
method the text returned from getText
method can have any length and will correspond to either the originally typed
text or to text supplied by one of the interceptors participating in
the key typed event processing.
getText
in class TypedTextInterceptor.Context
public void setText(String text, int caretPosition)
There is no restriction on the new text
set by this method, except that it must not be null
. It can
be of any length (including an empty string) and can even span multiple lines.
It is important to remember that the adjusted caret position is
relative to the new text. Therefore valid values for the caretPosition
parameter are <0, text.getLength()>
! The adjusted position
is not a document offset.
text
- The new text that will be inserted to a document.caretPosition
- The adjusted caret position inside the new text.
This position is relative to the new text. Valid values for this parameter
are <0, text.getLength()>
.public void setText(String text, int caretPosition, boolean formatNewLines)
There is no restriction on the new text
set by this method, except that it must not be null
. It can
be of any length (including an empty string) and can even span multiple lines.
It is important to remember that the adjusted caret position is
relative to the new text. Therefore valid values for the caretPosition
parameter are <0, text.getLength()>
! The adjusted position
is not a document offset.
text
- The new text that will be inserted to a document.caretPosition
- The adjusted caret position inside the new text.
This position is relative to the new text. Valid values for this parameter
are <0, text.getLength()>
.formatNewLines
- true if new lines in the provided text should be indented.public String getReplacedText()
The selected text is removed from document before insert
method.