モジュール java.desktop
パッケージ javax.swing.text

クラスDocumentFilter.FilterBypass

  • 含まれているクラス:
    DocumentFilter


    public abstract static class DocumentFilter.FilterBypass
    extends Object
    Documentへのコールバックを回避して、Documentを変更する場合に使用されます。 DocumentFilterをサポートするDocument実装では、次のメソッドがDocumentFilterから呼び出されたときに、DocumentFilterへのコールバックを実行しないようにする必要があります。
    導入されたバージョン:
    1.4
    • コンストラクタの詳細

      • FilterBypass

        public FilterBypass​()
    • メソッドの詳細

      • getDocument

        public abstract Document getDocument​()
        変更が行われているDocumentを返します。
        戻り値:
        removeStringやinsertStringが実行されるDocument
      • remove

        public abstract void remove​(int offset,
                                    int length)
                             throws BadLocationException
        DocumentFilterをバイパスして、テキストの指定領域を削除します。
        パラメータ:
        offset - 先頭からのオフセット>= 0
        length - 削除対象の文字数>= 0
        例外:
        BadLocationException - 削除範囲の一部がドキュメントの有効な部分でなかった場合。 例外内の位置は、最初に検出された不正な位置。
      • insertString

        public abstract void insertString​(int offset,
                                          String string,
                                          AttributeSet attr)
                                   throws BadLocationException
        DocumentFilterをバイパスして、指定テキストを挿入します。
        パラメータ:
        offset - コンテンツを挿入するドキュメント内のオフセット。0以上。 指定位置やその後ろの変更を追跡するすべての位置が移動します。
        string - 挿入する文字列
        attr - 挿入されたコンテンツに関連付ける属性。 属性がない場合はnullも可。
        例外:
        BadLocationException - 指定された挿入位置がドキュメント内の有効な位置でない場合
      • replace

        public abstract void replace​(int offset,
                                     int length,
                                     String string,
                                     AttributeSet attrs)
                              throws BadLocationException
        offsetからoffset+lengthまでのテキスト領域を削除し、textに置き換えます。
        パラメータ:
        offset - Documentでの位置
        length - 削除するテキストの長さ
        string - 挿入するテキスト。nullの場合、テキストは挿入されない
        attrs - 挿入されたテキストの属性を示すAttributeSet。nullも可。
        例外:
        BadLocationException - 指定された挿入位置がドキュメント内の有効な位置でない場合