JavaTM 2 Platform
Std. Ed. v1.3

javax.swing.text
クラス StringContent

java.lang.Object
  |
  +--javax.swing.text.StringContent
すべての実装インタフェース:
AbstractDocument.Content, Serializable

public final class StringContent
extends Object
implements AbstractDocument.Content, Serializable

比較的小さなドキュメントおよびデバッグには便利な、強引な実装である AbstractDocument.Content インタフェースの実装です。これは、文字コンテンツを単純な文字配列として管理します。これも効率的ではありません。

代わりに、ギャップバッファまたはピーステーブルの実装を使うことをお勧めします。このバッファはサイズが大きくなりません。

警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の運用や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。今後の Swing リリースでは、長期間の持続性をサポートする予定です。

関連項目:
直列化された形式

コンストラクタの概要
StringContent()
          新しい StringContent オブジェクトを作成します。
StringContent(int initialLength)
          指定された初期サイズで新しい StringContent オブジェクトを作成します。
 
メソッドの概要
 Position createPosition(int offset)
          コンテンツが変更されたときに変更を追跡するコンテンツ内の位置を作成します。
 void getChars(int where, int len, Segment chars)
          コンテンツの一部を取り出します。
protected  Vector getPositionsInRange(Vector v, int offset, int length)
          offsetoffset + length の範囲にある位置に対応する UndoPosRef のインスタンスを含むベクタを返します。
 String getString(int where, int len)
          コンテンツの一部を取り出します。
 UndoableEdit insertString(int where, String str)
          コンテンツに文字列を挿入します。
 int length()
          コンテンツの長さを返します。
 UndoableEdit remove(int where, int nitems)
          コンテンツの一部を削除します。
protected  void updateUndoPositions(Vector positions)
          positions のすべての UndoPosRef インスタンスの位置をリセットします。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

StringContent

public StringContent()
新しい StringContent オブジェクトを作成します。初期サイズのデフォルトは 10 です。

StringContent

public StringContent(int initialLength)
指定された初期サイズで新しい StringContent オブジェクトを作成します。長さが 1 より小さい場合、サイズ 1 が使われます。
パラメータ:
initialLength - 初期サイズ
メソッドの詳細

length

public int length()
コンテンツの長さを返します。
定義:
インタフェース AbstractDocument.Content 内の length
戻り値:
長さ >= 1
関連項目:
AbstractDocument.Content.length()

insertString

public UndoableEdit insertString(int where,
                                 String str)
                          throws BadLocationException
コンテンツに文字列を挿入します。
定義:
インタフェース AbstractDocument.Content 内の insertString
パラメータ:
where - 開始位置 >= 0 && < length()
str - 挿入する null 以外の文字列
戻り値:
元に戻すための UndoableEdit オブジェクト
例外:
BadLocationException - 指定された位置が無効な場合
関連項目:
AbstractDocument.Content.insertString(int, java.lang.String)

remove

public UndoableEdit remove(int where,
                           int nitems)
                    throws BadLocationException
コンテンツの一部を削除します。where + nitems は、length() より小さくなければなりません。
定義:
インタフェース AbstractDocument.Content 内の remove
パラメータ:
where - 開始位置 >= 0
nitems - 削除対象の文字数 >= 0
戻り値:
元に戻すための UndoableEdit オブジェクト
例外:
BadLocationException - 指定された位置が無効な場合
関連項目:
AbstractDocument.Content.remove(int, int)

getString

public String getString(int where,
                        int len)
                 throws BadLocationException
コンテンツの一部を取り出します。where + len は、length() 以下でなければなりません。
定義:
インタフェース AbstractDocument.Content 内の getString
パラメータ:
where - 開始位置 >= 0
len - 取り出す長さ >= 0
戻り値:
コンテンツを表す文字列。空の場合もある
例外:
BadLocationException - 指定された位置が無効な場合
関連項目:
AbstractDocument.Content.getString(int, int)

getChars

public void getChars(int where,
                     int len,
                     Segment chars)
              throws BadLocationException
コンテンツの一部を取り出します。where + len は、length() 以下でなければなりません。
定義:
インタフェース AbstractDocument.Content 内の getChars
パラメータ:
where - 開始位置 >= 0
len - 検索対象の文字数 >= 0
chars - 文字を返す先の Segment オブジェクト
例外:
BadLocationException - 指定された位置が無効な場合
関連項目:
AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)

createPosition

public Position createPosition(int offset)
                        throws BadLocationException
コンテンツが変更されたときに変更を追跡するコンテンツ内の位置を作成します。
定義:
インタフェース AbstractDocument.Content 内の createPosition
パラメータ:
offset - 位置を作成するオフセット >= 0
戻り値:
位置
例外:
BadLocationException - 指定された位置が無効な場合

getPositionsInRange

protected Vector getPositionsInRange(Vector v,
                                     int offset,
                                     int length)
offsetoffset + length の範囲にある位置に対応する UndoPosRef のインスタンスを含むベクタを返します。v が null ではない場合、一致する位置がそこに配置されます。結果の位置を持つベクタが返されます。
パラメータ:
v - 使用するベクタ。null の場合は新しいベクタが作成される
offset - 開始オフセット >= 0
length - 長さ >= 0
戻り値:
インスタンスのセット

updateUndoPositions

protected void updateUndoPositions(Vector positions)
positions のすべての UndoPosRef インスタンスの位置をリセットします。
パラメータ:
positions - インスタンスの位置

JavaTM 2 Platform
Std. Ed. v1.3

バグや機能要求の報告
さらに詳しい API リファレンスおよび開発者ドキュメントについては、 Java 2 SDK SE Developer Documentation を参照してください。このドキュメントには、概念、用語の定義、回避策、 実用的なコード例など、開発者を対象にした詳細な解説が掲載されています。

Java、Java 2D、JDBC は、米国およびその他の国における米国 Sun Microsystems, Inc. の商標もしくは登録商標です。
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.