📄 range.java
字号:
/*
* Copyright (c) 2000 World Wide Web Consortium,
* (Massachusetts Institute of Technology, Institut National de
* Recherche en Informatique et en Automatique, Keio University). All
* Rights Reserved. This program is distributed under the W3C's Software
* Intellectual Property License. This program is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
*/
package org.w3c.dom.ranges;
import org.w3c.dom.Node;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DOMException;
/**
* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>.
* @since DOM Level 2
*/
public interface Range {
/**
* Node within which the Range begins
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public Node getStartContainer()
throws DOMException;
/**
* Offset within the starting node of the Range.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public int getStartOffset()
throws DOMException;
/**
* Node within which the Range ends
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public Node getEndContainer()
throws DOMException;
/**
* Offset within the ending node of the Range.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public int getEndOffset()
throws DOMException;
/**
* TRUE if the Range is collapsed
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public boolean getCollapsed()
throws DOMException;
/**
* The deepest common ancestor container of the Range's two
* boundary-points.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public Node getCommonAncestorContainer()
throws DOMException;
/**
* Sets the attributes describing the start of the Range.
* @param refNodeThe <code>refNode</code> value. This parameter must be
* different from <code>null</code>.
* @param offsetThe <code>startOffset</code> value.
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor
* of <code>refNode</code> is an Entity, Notation, or DocumentType
* node.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater
* than the number of child units in <code>refNode</code>. Child units
* are 16-bit units if <code>refNode</code> is a type of CharacterData
* node (e.g., a Text or Comment node) or a ProcessingInstruction
* node. Child units are Nodes in all other cases.
* <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
* been invoked on this object.
*/
public void setStart(Node refNode,
int offset)
throws RangeException, DOMException;
/**
* Sets the attributes describing the end of a Range.
* @param refNodeThe <code>refNode</code> value. This parameter must be
* different from <code>null</code>.
* @param offsetThe <code>endOffset</code> value.
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if <code>refNode</code> or an ancestor
* of <code>refNode</code> is an Entity, Notation, or DocumentType
* node.
* @exception DOMException
* INDEX_SIZE_ERR: Raised if <code>offset</code> is negative or greater
* than the number of child units in <code>refNode</code>. Child units
* are 16-bit units if <code>refNode</code> is a type of CharacterData
* node (e.g., a Text or Comment node) or a ProcessingInstruction
* node. Child units are Nodes in all other cases.
* <br>INVALID_STATE_ERR: Raised if <code>detach()</code> has already
* been invoked on this object.
*/
public void setEnd(Node refNode,
int offset)
throws RangeException, DOMException;
/**
* Sets the start position to be before a node
* @param refNodeRange starts before <code>refNode</code>
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if the root container of
* <code>refNode</code> is not an Attr, Document, or DocumentFragment
* node or if <code>refNode</code> is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public void setStartBefore(Node refNode)
throws RangeException, DOMException;
/**
* Sets the start position to be after a node
* @param refNodeRange starts after <code>refNode</code>
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if the root container of
* <code>refNode</code> is not an Attr, Document, or DocumentFragment
* node or if <code>refNode</code> is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public void setStartAfter(Node refNode)
throws RangeException, DOMException;
/**
* Sets the end position to be before a node.
* @param refNodeRange ends before <code>refNode</code>
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if the root container of
* <code>refNode</code> is not an Attr, Document, or DocumentFragment
* node or if <code>refNode</code> is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public void setEndBefore(Node refNode)
throws RangeException, DOMException;
/**
* Sets the end of a Range to be after a node
* @param refNodeRange ends after <code>refNode</code>.
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if the root container of
* <code>refNode</code> is not an Attr, Document or DocumentFragment
* node or if <code>refNode</code> is a Document, DocumentFragment,
* Attr, Entity, or Notation node.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public void setEndAfter(Node refNode)
throws RangeException, DOMException;
/**
* Collapse a Range onto one of its boundary-points
* @param toStartIf TRUE, collapses the Range onto its start; if FALSE,
* collapses it onto its end.
* @exception DOMException
* INVALID_STATE_ERR: Raised if <code>detach()</code> has already been
* invoked on this object.
*/
public void collapse(boolean toStart)
throws DOMException;
/**
* Select a node and its contents
* @param refNodeThe node to select.
* @exception RangeException
* INVALID_NODE_TYPE_ERR: Raised if an ancestor of <code>refNode</code>
* is an Entity, Notation or DocumentType node or if
* <code>refNode</code> is a Document, DocumentFragment, Attr, Entity,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -