public class GapContent extends Object implements AbstractDocument.Content, Serializable
また、変更を追跡する位置を管理するのも一般的に簡単です。 位置の実装(マーク)は配列インデックスを格納し、現在のギャップ位置から逐次位置を簡単に計算できます。 変更ではギャップの移動時に新旧ギャップ境界間のマークに対する更新を必要とするだけなので、マークの更新は一般に非常に手軽です。 マークはソートされた状態で格納されるので、2等分探索ですばやく見つけられます。 これはマークを追加する手間を増大させる一方で、マークの更新を維持する手間を減らします。
| コンストラクタ | 説明 | 
|---|---|
| GapContent() | 新しいGapContentオブジェクトを作成します。 | 
| GapContent(int initialLength) | 指定された初期サイズで新しいGapContentオブジェクトを生成します。 | 
| 修飾子と型 | メソッド | 説明 | 
|---|---|---|
| protected Object | allocateArray(int len) | 項目を格納するための適切な型の配列を割り当てます。配列の型は、サブクラスで決定します。 | 
| Position | createPosition(int offset) | コンテンツが変更されたときに変更を追跡するコンテンツ内の位置を作成します。 | 
| protected Object | getArray() | 配列にアクセスします。 | 
| protected int | getArrayLength() | 割り当てられた配列の長さを取得します。 | 
| void | getChars(int where, int len, Segment chars) | コンテンツの一部を取り出します。 | 
| protected int | getGapEnd() | ギャップの終端にアクセスします。 | 
| protected int | getGapStart() | ギャップの先頭にアクセスします。 | 
| protected Vector | getPositionsInRange(Vector v, int offset, int length) | offsetからoffset+lengthの範囲にある位置に対応するUndoPosRefのインスタンスを含むベクターを返します。 | 
| String | getString(int where, int len) | コンテンツの一部を取り出します。 | 
| UndoableEdit | insertString(int where, String str) | コンテンツに文字列を挿入します。 | 
| int | length() | コンテンツの長さを返します。 | 
| UndoableEdit | remove(int where, int nitems) | コンテンツの一部を削除します。 | 
| protected void | replace(int position, int rmSize, Object addItems, int addSize) | 指定されたストレージ内の論理的位置を、指定された新規項目に置き換えます。 | 
| protected void | resetMarksAtZero() | オフセットが0のマークをすべてリセットして、インデックスも0になるようにします。 | 
| protected void | shiftEnd(int newSize) | ギャップを拡大し、これにより、必要なデータを移動して適切なマークを更新します。 | 
| protected void | shiftGap(int newGapStart) | ギャップの開始位置を新しい位置に移動しますが、ギャップのサイズは変更しません。 | 
| protected void | shiftGapEndUp(int newGapEnd) | ギャップの終端を上方に調節します。 | 
| protected void | shiftGapStartDown(int newGapStart) | ギャップの終端を下方に調節します。 | 
| protected void | updateUndoPositions(Vector positions, int offset, int length) | positionsのすべてのUndoPosRefインスタンスの位置をリセットします。 | 
public GapContent()
public GapContent(int initialLength)
initialLength - 初期サイズprotected Object allocateArray(int len)
protected int getArrayLength()
public int length()
length、インタフェースAbstractDocument.ContentAbstractDocument.Content.length()public UndoableEdit insertString(int where, String str) throws BadLocationException
insertString、インタフェースAbstractDocument.Contentwhere - 開始位置。0以上で、length()より小さいstr - 挿入するnull以外の文字列BadLocationException - 指定された位置が無効な場合AbstractDocument.Content.insertString(int, java.lang.String)public UndoableEdit remove(int where, int nitems) throws BadLocationException
remove、インタフェースAbstractDocument.Contentwhere - 開始位置。0以上で、where + nitemsがlength()より小さいnitems - 削除対象の文字数>= 0BadLocationException - 指定された位置が無効な場合AbstractDocument.Content.remove(int, int)public String getString(int where, int len) throws BadLocationException
getString、インタフェースAbstractDocument.Contentwhere - 開始位置>= 0len - 取り出す長さ>= 0BadLocationException - 指定された位置が無効な場合AbstractDocument.Content.getString(int, int)public void getChars(int where,
                     int len,
                     Segment chars)
              throws BadLocationException
getChars、インタフェースAbstractDocument.Contentwhere - 開始位置。0以上で、where + lenがlength()以下len - 取得対象の文字数>= 0chars - 文字を返す先のSegmentオブジェクトBadLocationException - 指定された位置が無効な場合AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)public Position createPosition(int offset) throws BadLocationException
createPosition、インタフェースAbstractDocument.Contentoffset - 追跡対象のオフセット>= 0BadLocationException - 指定された位置が無効な場合protected void shiftEnd(int newSize)
protected void shiftGap(int newGapStart)
protected void resetMarksAtZero()
protected void shiftGapStartDown(int newGapStart)
protected void shiftGapEndUp(int newGapEnd)
protected Vector getPositionsInRange(Vector v, int offset, int length)
offsetからoffset+lengthの範囲にある位置に対応するUndoPosRefのインスタンスを含むベクターを返します。 vがnullではない場合、一致する位置がそこに配置されます。 結果として得られる位置を持つベクターが返されます。 v - 使用するベクター。nullの場合は新しいベクターが作成されるoffset - 開始オフセット>= 0length - 長さ>= 0protected void updateUndoPositions(Vector positions, int offset, int length)
positionsのすべてのUndoPosRefインスタンスの位置をリセットします。
 これは内部での使用を目的としていて、一般にはサブクラスを対象にしていません。
positions - リセット対象のUndoPosRefのインスタンスprotected final Object getArray()
protected final int getGapStart()
protected final int getGapEnd()
protected void replace(int position,
                       int rmSize,
                       Object addItems,
                       int addSize)
position - 置換えを行う位置。 これは基になるストレージ配列内の位置ではなく、モデル化される連続するスペース内の位置です。 rmSize - 削除する項目の数addItems - ストレージ内に配置する新規項目。 バグまたは機能を送信 
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。 
 Copyright © 1993, 2025, Oracle and/or its affiliates.  All rights reserved.  Use is subject to license terms.  Documentation Redistribution Policyも参照してください。