Class SimpleRange
java.lang.Object
org.htmlunit.html.impl.SimpleRange
- All Implemented Interfaces:
Serializable
Simple implementation of an Range.
- Author:
- Marc Guillemot, Daniel Gredler, James Phillpotts, Ahmed Ashour, Ronald Brill
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a range without any content.SimpleRange(DomNode node) Constructs a range for the specified element.SimpleRange(DomNode node, int offset) Constructs a range for the provided element and start and end offset.SimpleRange(DomNode startNode, int startOffset, DomNode endNode, int endOffset) Constructs a range for the provided elements and offsets. -
Method Summary
Modifier and TypeMethodDescriptionDuplicates the contents of this.Produces a new SimpleRange whose boundary-points are equal to the boundary-points of this.voidcollapse(boolean toStart) Collapse this range onto one of its boundary-points.voidRemoves the contents of this range from the containing document or document fragment without returning a reference to the removed content.booleanMoves the contents of a Range from the containing document or document fragment to a new DocumentFragment.intintinthashCode()voidinsertNode(DomNode newNode) Inserts a node into the Document or DocumentFragment at the start of the Range.booleanvoidselectNode(DomNode node) Select a node and its contents.voidselectNodeContents(DomNode node) Select the contents within a node.voidSets the attributes describing the end.voidSets the attributes describing the start.voidsurroundContents(DomNode newParent) Reparents the contents of the Range to the given node and inserts the node at the position of the start of the Range.toString()
-
Constructor Details
-
SimpleRange
public SimpleRange()Constructs a range without any content. -
SimpleRange
Constructs a range for the specified element.- Parameters:
node- the node for the range
-
SimpleRange
Constructs a range for the provided element and start and end offset.- Parameters:
node- the node for the rangeoffset- the start and end offset
-
SimpleRange
-
-
Method Details
-
cloneContents
Duplicates the contents of this.- Returns:
- DocumentFragment that contains content equivalent to this
-
cloneRange
Produces a new SimpleRange whose boundary-points are equal to the boundary-points of this.- Returns:
- duplicated simple
-
collapse
public void collapse(boolean toStart) Collapse this range onto one of its boundary-points.- Parameters:
toStart- if true, collapses the Range onto its start; else collapses it onto its end.
-
deleteContents
public void deleteContents()Removes the contents of this range from the containing document or document fragment without returning a reference to the removed content. -
extractContents
Moves the contents of a Range from the containing document or document fragment to a new DocumentFragment.- Returns:
- DocumentFragment containing the extracted contents
- Throws:
DOMException
-
isCollapsed
- Returns:
- true if startContainer equals endContainer and startOffset equals endOffset
- Throws:
DOMException
-
getCommonAncestorContainer
- Returns:
- the deepest common ancestor container of this range's two boundary-points.
- Throws:
DOMException
-
getEndContainer
- Returns:
- the Node within which this range ends
-
getEndOffset
public int getEndOffset()- Returns:
- offset within the ending node of this
-
getStartContainer
- Returns:
- the Node within which this range begins
-
getStartOffset
public int getStartOffset()- Returns:
- offset within the starting node of this
-
insertNode
Inserts a node into the Document or DocumentFragment at the start of the Range. If the container is a Text node, this will be split at the start of the Range (as if the Text node's splitText method was performed at the insertion point) and the insertion will occur between the two resulting Text nodes. Adjacent Text nodes will not be automatically merged. If the node to be inserted is a DocumentFragment node, the children will be inserted rather than the DocumentFragment node itself.- Parameters:
newNode- The node to insert at the start of the Range
-
selectNode
Select a node and its contents.- Parameters:
node- The node to select.
-
selectNodeContents
Select the contents within a node.- Parameters:
node- Node to select from
-
setEnd
Sets the attributes describing the end.- Parameters:
refNode- the refNodeoffset- offset
-
setStart
Sets the attributes describing the start.- Parameters:
refNode- the refNodeoffset- offset
-
surroundContents
Reparents the contents of the Range to the given node and inserts the node at the position of the start of the Range.- Parameters:
newParent- The node to surround the contents with.
-
equals
-
hashCode
-
toString
-
containedNodes
-