public interface Range
- 導入されたバージョン:
- 9、DOMレベル2
-
フィールドのサマリー
修飾子と型フィールド説明static final short
sourceRange
の終了境界点とcompareBoundaryPoints
が呼び出されるRangeの終了境界点を比較します。static final short
sourceRange
の終了境界点とcompareBoundaryPoints
が呼び出されるRangeの開始境界点を比較します。static final short
sourceRange
の開始境界点とcompareBoundaryPoints
が呼び出されるRangeの終了境界点を比較します。static final short
sourceRange
の開始境界点とcompareBoundaryPoints
が呼び出されるRangeの開始境界点を比較します。 -
メソッドのサマリー
修飾子と型メソッド説明Rangeの内容を複製します。このRangeの境界点と同等の境界点を持つ新規Rangeを作成します。void
collapse
(boolean toStart) 境界点の1つにRangeを折りたたみます。short
compareBoundaryPoints
(short how, Range sourceRange) ドキュメントの2つのRangeの境界点を比較します。void
削除された内容への参照を返すことなく、含まれているドキュメントまたはドキュメントのフラグメントからRangeの内容を削除します。void
detach()
Rangeが使用されなくなったことと、実装がこのRangeに関連するリソースを放棄してもかまわないことを示すために呼び出されます。含まれているドキュメントまたはドキュメントのフラグメントからRangeの内容を移動します。boolean
Rangeが折りたたまれている場合はtrue。Rangeの2つの境界点のもっとも深い共通上位コンテナ。内部でRangeが終了するノード。int
Rangeの終了ノード内のオフセット。内部でRangeが始まるノード。int
Rangeの開始ノード内のオフセット。void
insertNode
(Node newNode) ノードをDocumentまたはDocumentFragmentのRangeの開始位置に挿入します。void
selectNode
(Node refNode) ノードとその内容を選択します。void
selectNodeContents
(Node refNode) ノード内の内容を選択します。void
Rangeの終了を記述する属性を設定します。void
setEndAfter
(Node refNode) Rangeの終了をノードのあとに設定します。void
setEndBefore
(Node refNode) 終了位置をノードの前に設定します。void
Rangeの開始を記述する属性を設定します。void
setStartAfter
(Node refNode) 開始位置をノードのあとに設定します。void
setStartBefore
(Node refNode) 開始位置をノードの前に設定します。void
surroundContents
(Node newParent) Rangeの内容を所定のノードの親として再設定し、再設定したノードをRangeの開始位置に挿入します。toString()
Rangeの内容を文字列として返します。
-
フィールド詳細
-
START_TO_START
static final short START_TO_STARTsourceRange
の開始境界点とcompareBoundaryPoints
が呼び出されるRangeの開始境界点を比較します。- 関連項目:
-
START_TO_END
static final short START_TO_ENDsourceRange
の開始境界点とcompareBoundaryPoints
が呼び出されるRangeの終了境界点を比較します。- 関連項目:
-
END_TO_END
static final short END_TO_ENDsourceRange
の終了境界点とcompareBoundaryPoints
が呼び出されるRangeの終了境界点を比較します。- 関連項目:
-
END_TO_START
static final short END_TO_STARTsourceRange
の終了境界点とcompareBoundaryPoints
が呼び出されるRangeの開始境界点を比較します。- 関連項目:
-
-
メソッドの詳細
-
getStartContainer
Node getStartContainer() throws DOMException内部でRangeが始まるノード。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
getStartOffset
int getStartOffset() throws DOMExceptionRangeの開始ノード内のオフセット。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
getEndContainer
Node getEndContainer() throws DOMException内部でRangeが終了するノード。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
getEndOffset
int getEndOffset() throws DOMExceptionRangeの終了ノード内のオフセット。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
getCollapsed
boolean getCollapsed() throws DOMExceptionRangeが折りたたまれている場合はtrue。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
getCommonAncestorContainer
Node getCommonAncestorContainer() throws DOMExceptionRangeの2つの境界点のもっとも深い共通上位コンテナ。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
setStart
void setStart(Node refNode, int offset) throws RangeException, DOMException Rangeの開始を記述する属性を設定します。- パラメータ:
refNode
-refNode
値。 このパラメータはnull
以外でなければならない。offset
-startOffset
値。- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
またはrefNode
の上位がEntity、Notation、またはDocumentTypeノードの場合に発生する。DOMException
- INDEX_SIZE_ERR:offset
が負であるか、refNode
の子の単位数よりも大きい場合に発生する。refNode
がCharacterDataノード(TextまたはCommentノードなど)またはProcessingInstructionノードの型の場合、子の単位は16ビット単位である。 他のすべてのケースで、子の単位はNodesである。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
setEnd
void setEnd(Node refNode, int offset) throws RangeException, DOMException Rangeの終了を記述する属性を設定します。- パラメータ:
refNode
-refNode
値。 このパラメータはnull
以外でなければならない。offset
-endOffset
値。- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
またはrefNode
の上位がEntity、Notation、またはDocumentTypeノードの場合に発生する。DOMException
- INDEX_SIZE_ERR:offset
が負であるか、refNode
の子の単位数よりも大きい場合に発生する。refNode
がCharacterDataノード(TextまたはCommentノードなど)またはProcessingInstructionノードの型の場合、子の単位は16ビット単位である。 他のすべてのケースで、子の単位はNodesである。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
setStartBefore
void setStartBefore(Node refNode) throws RangeException, DOMException 開始位置をノードの前に設定します。- パラメータ:
refNode
- RangeはrefNode
の前から始まる- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
がAttr、Document、またはDocumentFragmentノードではない場合、またはrefNode
がDocument、DocumentFragment、Attr、Entity、またはNotationノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
setStartAfter
void setStartAfter(Node refNode) throws RangeException, DOMException 開始位置をノードのあとに設定します。- パラメータ:
refNode
- RangeはrefNode
のあとから始まる- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
がAttr、Document、またはDocumentFragmentノードではない場合、またはrefNode
がDocument、DocumentFragment、Attr、Entity、またはNotationノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
setEndBefore
void setEndBefore(Node refNode) throws RangeException, DOMException 終了位置をノードの前に設定します。- パラメータ:
refNode
- RangeはrefNode
の前で終わる- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
がAttr、Document、またはDocumentFragmentノードではない場合、またはrefNode
がDocument、DocumentFragment、Attr、Entity、またはNotationノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
setEndAfter
void setEndAfter(Node refNode) throws RangeException, DOMException Rangeの終了をノードのあとに設定します。- パラメータ:
refNode
- RangeはrefNode
のあとで終わる。- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
がAttr、Document、またはDocumentFragmentノードではない場合、またはrefNode
がDocument、DocumentFragment、Attr、Entity、またはNotationノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
collapse
void collapse(boolean toStart) throws DOMException 境界点の1つにRangeを折りたたみます。- パラメータ:
toStart
- trueの場合、Rangeを開始境界点に折りたたみ、falseの場合、終了境界点に折りたたむ。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
selectNode
void selectNode(Node refNode) throws RangeException, DOMException ノードとその内容を選択します。- パラメータ:
refNode
- 選択するノード。- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
の上位がEntity、Notation、またはDocumentTypeノードの場合、またはrefNode
がDocument、DocumentFragment、Attr、Entity、またはNotationノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
selectNodeContents
void selectNodeContents(Node refNode) throws RangeException, DOMException ノード内の内容を選択します。- パラメータ:
refNode
- 内容が選択されるノード- 例外:
RangeException
- INVALID_NODE_TYPE_ERR:refNode
またはrefNode
の上位がEntity、Notation、またはDocumentTypeノードの場合に発生する。DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
WRONG_DOCUMENT_ERR:refNode
が、この範囲を作成したドキュメントとは異なるドキュメントから作成された場合に発生する。
-
compareBoundaryPoints
short compareBoundaryPoints(short how, Range sourceRange) throws DOMException ドキュメントの2つのRangeの境界点を比較します。- パラメータ:
how
- 前述のように比較の種類を表すコード。sourceRange
- 現在のRange
の比較対象のRange
。- 戻り値:
- Rangeの対応する境界点が
sourceRange
の対応する境界点の前、同等、またはあとかに応じて、それぞれ -1、0、または1。 - 例外:
DOMException
- WRONG_DOCUMENT_ERR: 2つのRangeが同じDocumentまたはDocumentFragmentにない場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
deleteContents
void deleteContents() throws DOMException削除された内容への参照を返すことなく、含まれているドキュメントまたはドキュメントのフラグメントからRangeの内容を削除します。- 例外:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Rangeの内容の一部が読取り専用の場合、またはRangeの内容を含むノードのいずれかが読取り専用の場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
extractContents
DocumentFragment extractContents() throws DOMException含まれているドキュメントまたはドキュメントのフラグメントからRangeの内容を移動します。- 戻り値:
- 抽出された内容を含んでいるDocumentFragment
- 例外:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Rangeの内容の一部が読取り専用の場合、またはRangeの内容を含むノードのいずれかが読取り専用の場合に発生する。
HIERARCHY_REQUEST_ERR: DocumentTypeノードが新しいDocumentFragmentに抽出される場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
cloneContents
DocumentFragment cloneContents() throws DOMExceptionRangeの内容を複製します。- 戻り値:
- このRangeと同等の内容を含むDocumentFragment
- 例外:
DOMException
- HIERARCHY_REQUEST_ERR: DocumentTypeノードが新しいDocumentFragmentに抽出される場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
insertNode
void insertNode(Node newNode) throws DOMException, RangeException ノードをDocumentまたはDocumentFragmentのRangeの開始位置に挿入します。 コンテナがTextノードの場合、このノードはTextノードのsplitTextメソッドが挿入点で実行されたときのようにRangeの開始位置で分割されます。 隣接するTextノードは自動的に結合されます。 挿入されるノードがDocumentFragmentノードの場合、DocumentFragmentノード自体ではなくその子が挿入されます。- パラメータ:
newNode
- Rangeの開始位置に挿入されるノード- 例外:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Rangeの開始の上位コンテナが読取り専用の場合に発生する。
WRONG_DOCUMENT_ERR:newNode
およびRangeの開始のコンテナが同じドキュメントから作成されていなかった場合に発生する。
HIERARCHY_REQUEST_ERR: Rangeの開始のコンテナがnewNode
の型の子を許可しない型のコンテナの場合、またはnewNode
がコンテナの上位である場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。RangeException
- INVALID_NODE_TYPE_ERR:newNode
がAttr、Entity、Notation、またはDocumentノードの場合に発生する。
-
surroundContents
void surroundContents(Node newParent) throws DOMException, RangeException Rangeの内容を所定のノードの親として再設定し、再設定したノードをRangeの開始位置に挿入します。- パラメータ:
newParent
- 内容を囲むノード。- 例外:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Rangeのどちらかの境界点の上位コンテナが読取り専用の場合に発生する。
WRONG_DOCUMENT_ERR:newParent
およびRangeの開始のコンテナが同じドキュメントから作成されていなかった場合に発生する。
HIERARCHY_REQUEST_ERR: Rangeの開始のコンテナがnewParent
の型の子を許可しない型のコンテナである場合、またはnewParent
がコンテナの上位の場合、あるいはnode
が、node
の型によって許可されていない型の子ノードで終わる場合に発生する。
INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。RangeException
- BAD_BOUNDARYPOINTS_ERR: Rangeが部分的にテキスト以外のノードを選択した場合に発生する。
INVALID_NODE_TYPE_ERR:node
がAttr、Entity、DocumentType、Notation、DocumentまたはDocumentFragmentノードの場合に発生する。
-
cloneRange
Range cloneRange() throws DOMExceptionこのRangeの境界点と同等の境界点を持つ新規Rangeを作成します。- 戻り値:
- 重複するRange
- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
toString
String toString() throws DOMExceptionRangeの内容を文字列として返します。 この文字列には、マークアップではなくデータの文字だけが含まれます。- オーバーライド:
toString
、クラスObject
- 戻り値:
- Rangeの内容
- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-
detach
void detach() throws DOMExceptionRangeが使用されなくなったことと、実装がこのRangeに関連するリソースを放棄してもかまわないことを示すために呼び出されます。 これ以降、このRange上でメソッドや属性を取得するものを呼び出すと、エラー・コードINVALID_STATE_ERR
でDOMException
がスローされます。- 例外:
DOMException
- INVALID_STATE_ERR: このオブジェクト上ですでにdetach()
が呼び出されている場合に発生する。
-