org.netbeans.modules.editor.lib2/1 1.43.1 10

org.netbeans.spi.editor.typinghooks
Class TypedTextInterceptor.MutableContext

java.lang.Object
  extended by org.netbeans.spi.editor.typinghooks.TypedTextInterceptor.Context
      extended by org.netbeans.spi.editor.typinghooks.TypedTextInterceptor.MutableContext
Enclosing interface:
TypedTextInterceptor

public static final class TypedTextInterceptor.MutableContext
extends TypedTextInterceptor.Context

This context class allows to modify the insertion text and the caret position after the text is inserted into a document. Apart from that it provides exactly the same information as its superclass Context.


Method Summary
 String getText()
          Gets the insertion text.
 void setText(String text, int caretPosition)
          Sets the insertion text and adjusted caret position.
 
Methods inherited from class org.netbeans.spi.editor.typinghooks.TypedTextInterceptor.Context
getComponent, getDocument, getOffset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getText

public String getText()
Description copied from class: TypedTextInterceptor.Context
Gets the insertion text. This is the text that was typed by the user or its modification provided by one of the interceptors.

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.

Overrides:
getText in class TypedTextInterceptor.Context
Returns:
The insertion text.

setText

public void setText(String text,
                    int caretPosition)
Sets the insertion text and adjusted caret position. This method can be used for modifying text typed by a user that would normally be inserted into a document.

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.

Parameters:
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()>.

org.netbeans.modules.editor.lib2/1 1.43.1 10

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.