public static final class TypedBreakInterceptor.MutableContext extends TypedBreakInterceptor.Context
|Modifier and Type||Method and Description|
Sets the insertion text and adjusted caret position.
getBreakInsertOffset, getCaretOffset, getComponent, getDocument
public void setText(String text, int breakInsertPosition, int caretPosition, int... reindentBlocks)
There is no restriction on the new text
set by this method, except that it must not be
null and must contain at least
one line break. It can be of any length and can even span multiple lines.
It is important to remember that the values of the position parameters are
relative to the new text. Therefore valid values for the
parameter, for example, are
<0, text.getLength()>! The position parameters
are not document offsets.
The following rules have to be obeyed otherwise an
will be thrown:
texthas to contain at least one line break '\n' character.
breakInsertPosition, if specified, has to point to the most important line break character in the
text(eg. an interceptor can actually insert several lines, but one of them is always considered the most significant and its line break character position is where
breakInsertPositionshould point at.
caretPosition, if specified, has to point somewhere within the
reindentBlocks, if specified, are pairs of positions within the
text. In each pair the first number denotes the starting position of a region that will be reindented. The ending position of that region is denoted by the second number in the pair. Therfore the first number has to be lower or equal to the second number.
text- The new text that will be inserted to a document. It must contain at least one line break '\n' character.
breakInsertPosition- The position within the
textwhere the most significant line break character is. If
-1, the position of the first line break character in the
textwill be used.
caretPosition- The position within the
textwhere the caret will be placed after the text is inserted in the document. If
breakInsertPosition + 1will be used.
reindentBlocks- The list of position pairs that determine areas within the
textthat will be reindented after the
textis inserted in the document. Can be
nullor zero length array in which case only the line containing the
caretPositionwill be reindented. If specified, it must contain an even number of elements.
IllegalArgumentException- If the parameters passed in violate the rules specified above.
Built on July 6 2021. | Copyright © 2017-2021 Apache Software Foundation. All Rights Reserved.