Top Description Fields Constructors Methods
org.apache.xerces.dom

public Class RangeImpl

extends Object
implements Range
Class Inheritance
All Implemented Interfaces
org.w3c.dom.ranges.Range
Imports
java.util.ArrayList, org.w3c.dom.CharacterData, .DOMException, .DocumentFragment, .Node, org.w3c.dom.ranges.Range, .RangeException

The RangeImpl class implements the org.w3c.dom.range.Range interface.

Please see the API documentation for the interface classes and use the interfaces in your client programs.

Version
$Id: RangeImpl.java 515302 2007-03-06 21:07:10Z mrglavas $

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
private Node
private boolean
private DocumentImpl
private Node
private int
private boolean
private Node
private Node
fRemoveChild

This function is called within Range instead of Node.removeChild, so that the range can remember that it is actively removing this child.

private Node
private Node
private int

Constructor Summary

AccessConstructor and Description
public
RangeImpl(DocumentImpl document)

The constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
checkIndex(Node refNode, int offset)

public DocumentFragment
cloneContents()

Implements org.w3c.dom.ranges.Range.cloneContents.

Duplicates the contents of a Range
public Range
cloneRange()

Implements org.w3c.dom.ranges.Range.cloneRange.

Produces a new Range whose boundary-points are equal to the boundary-points of the Range.
public void
collapse(boolean
If TRUE, collapses the Range onto its start; if FALSE, collapses it onto its end.
toStart
)

Implements org.w3c.dom.ranges.Range.collapse.

Collapse a Range onto one of its boundary-points
public short
compareBoundaryPoints(short
A code representing the type of comparison, as defined above.
how
,
Range
The Range on which this current Range is compared to.
sourceRange
)

Implements org.w3c.dom.ranges.Range.compareBoundaryPoints.

Compare the boundary-points of two Ranges in a document.
public void
deleteContents()

Implements org.w3c.dom.ranges.Range.deleteContents.

Removes the contents of a Range from the containing document or document fragment without returning a reference to the removed content.
pack-priv void
deleteData(CharacterData node, int offset, int count)

This function inserts text into a Node and invokes a method to fix-up all other Ranges.

public void
detach()

Implements org.w3c.dom.ranges.Range.detach.

Called to indicate that the Range is no longer in use and that the implementation may relinquish any resources associated with this Range.
public DocumentFragment
extractContents()

Implements org.w3c.dom.ranges.Range.extractContents.

Moves the contents of a Range from the containing document or document fragment to a new DocumentFragment.
public boolean
getCollapsed()

Implements org.w3c.dom.ranges.Range.getCollapsed.

TRUE if the Range is collapsed
public Node
getCommonAncestorContainer()

Implements org.w3c.dom.ranges.Range.getCommonAncestorContainer.

The deepest common ancestor container of the Range's two boundary-points.
public Node
getEndContainer()

Implements org.w3c.dom.ranges.Range.getEndContainer.

Node within which the Range ends
public int
getEndOffset()

Implements org.w3c.dom.ranges.Range.getEndOffset.

Offset within the ending node of the Range.
private Node
getRootContainer(Node node)

Given a node, calculate what the Range's root container for that node would be.

private Node

Returns:

Returns either a child node of the container or the container itself.
getSelectedNode
(Node
A container node
container
,
int
An offset within the container for which a selected node should be computed. If the offset is less than zero, or if the offset is greater than the number of children, the container is returned.
offset
)

Utility method to retrieve a child node by index.

public Node
getStartContainer()

Implements org.w3c.dom.ranges.Range.getStartContainer.

Node within which the Range begins
public int
getStartOffset()

Implements org.w3c.dom.ranges.Range.getStartOffset.

Offset within the starting node of the Range.
private boolean
hasLegalRootContainer(Node node)

Finds the root container for the given node and determines if that root container is legal with respect to the DOM 2 specification.

pack-priv int
indexOf(Node child, Node parent)

what is the index of the child in the parent

pack-priv void
insertData(CharacterData node, int index, String insert)

This function inserts text into a Node and invokes a method to fix-up all other Ranges.

public void
insertedNodeFromDOM(Node node)

This function is called from the DOM.

public void
insertNode(Node
The node to insert at the start of the Range
newNode
)

Implements org.w3c.dom.ranges.Range.insertNode.

Inserts a node into the Document or DocumentFragment at the start of the Range.
pack-priv boolean
isAncestorOf(Node a, Node b)

is a an ancestor of b ?

private boolean
isLegalContainedNode(Node node)

Returns true IFF the given node can be contained by a range.

private boolean
isLegalContainer(Node node)

Returns true IFF the given node can serve as a container for a range's boundary points.

pack-priv Node
nextNode(Node node, boolean visitChildren)

pack-priv void
receiveDeletedText(CharacterDataImpl node, int offset, int count)

This function is called from DOM.

pack-priv void
receiveInsertedText(CharacterDataImpl node, int index, int len)

This function is called from DOM.

pack-priv void
receiveReplacedText(CharacterDataImpl node)

This function is called from DOM.

pack-priv void
receiveSplitData(Node node, Node newNode, int offset)

Fix up this Range if another Range has split a Text Node into 2 Nodes.

pack-priv Node
removeChild(Node parent, Node child)

pack-priv void
removeNode(Node node)

This function must be called by the DOM _BEFORE_ a node is deleted, because at that time it is connected in the DOM tree, which we depend on.

public void
selectNode(Node
The node to select.
refNode
)

Implements org.w3c.dom.ranges.Range.selectNode.

Select a node and its contents
public void
selectNodeContents(Node
Node to select from
refNode
)

Implements org.w3c.dom.ranges.Range.selectNodeContents.

Select the contents within a node
public void
setEnd(Node
The refNode value. This parameter must be different from null.
refNode
,
int
The endOffset value.
offset
)

Implements org.w3c.dom.ranges.Range.setEnd.

Sets the attributes describing the end of a Range.
public void
setEndAfter(Node
Range ends after refNode.
refNode
)

Implements org.w3c.dom.ranges.Range.setEndAfter.

Sets the end of a Range to be after a node
public void
setEndBefore(Node
Range ends before refNode
refNode
)

Implements org.w3c.dom.ranges.Range.setEndBefore.

Sets the end position to be before a node.
public void
setStart(Node
The refNode value. This parameter must be different from null.
refNode
,
int
The startOffset value.
offset
)

Implements org.w3c.dom.ranges.Range.setStart.

Sets the attributes describing the start of the Range.
public void
setStartAfter(Node
Range starts after refNode
refNode
)

Implements org.w3c.dom.ranges.Range.setStartAfter.

Sets the start position to be after a node
public void
setStartBefore(Node
Range starts before refNode
refNode
)

Implements org.w3c.dom.ranges.Range.setStartBefore.

Sets the start position to be before a node
pack-priv void
signalSplitData(Node node, Node newNode, int offset)

Signal other Ranges to update their start/end containers/offsets.

public void
surroundContents(Node
The node to surround the contents with.
newParent
)

Implements org.w3c.dom.ranges.Range.surroundContents.

Reparents the contents of the Range to the given node and inserts the node at the position of the start of the Range.
public String
toString()

Overrides java.lang.Object.toString.

Implements org.w3c.dom.ranges.Range.toString.

Returns the contents of a Range as a string.
private Node

Returns:

Returns a node that is the result of visiting the node. If the traversal operation is DELETE_CONTENTS the return value is null.
traverseCharacterDataNode
(Node
The node to be traversed.
n
,
boolean
Is true if we are traversing the node as part of navigating the "left boundary" of the range. If this value is false, it implies we are navigating the "right boundary" of the range.
isLeft
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will simply return the original node.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will return a cloned node.
  3. DELETE_CONTENTS - will delete the node from it's parent, but will return null.
how
)

Utility method for traversing a node containing character data (either a Text, CDATASection, Comment or ProcessingInstruction node) that we know a-priori to be on a left or right boundary of the range.

private DocumentFragment

Returns:

Returns a document fragment containing any copied or extracted nodes. If the how parameter was DELETE_CONTENTS, the return value is null.
traverseCommonAncestors
(Node
Given a common ancestor of the start and end containers, this parameter is the ancestor (or self) of the start container that is a direct child of the common ancestor.
startAncestor
,
Node
Given a common ancestor of the start and end containers, this parameter is the ancestor (or self) of the end container that is a direct child of the common ancestor.
endAncestor
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a document fragment containing the range's content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but sill produced cloned content in a document fragment
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes.
how
)

Visits the nodes selected by this range when we know a-priori that the start and end containers are not the same, and we also know that neither the start nor end container is an ancestor of the other.

private DocumentFragment

Returns:

Returns a document fragment containing any copied or extracted nodes. If the how parameter was DELETE_CONTENTS, the return value is null.
traverseCommonEndContainer
(Node
The ancestor of the start container that is a direct child of the end container.
startAncestor
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a document fragment containing the range's content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but sill produced cloned content in a document fragment
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes.
how
)

Visits the nodes selected by this range when we know a-priori that the start and end containers are not the same, but the end container is an ancestor of the start container.

private DocumentFragment

Returns:

Returns a document fragment containing any copied or extracted nodes. If the how parameter was DELETE_CONTENTS, the return value is null.
traverseCommonStartContainer
(Node
The ancestor of the end container that is a direct child of the start container.
endAncestor
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a document fragment containing the range's content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but sill produced cloned content in a document fragment
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes.
how
)

Visits the nodes selected by this range when we know a-priori that the start and end containers are not the same, but the start container is an ancestor of the end container.

private DocumentFragment

Returns:

Returns a document fragment containing any copied or extracted nodes. If the how parameter was DELETE_CONTENTS, the return value is null.
traverseContents
(int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a document fragment containing the range's content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but sill produced cloned content in a document fragment
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes.
how
)

This is the master routine invoked to visit the nodes selected by this range.

private Node

Returns:

Returns a node that is the result of visiting the node. If the traversal operation is DELETE_CONTENTS the return value is null.
traverseFullySelected
(Node
The node to be traversed.
n
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will simply return the original node.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will return a cloned node.
  3. DELETE_CONTENTS - will delete the node from it's parent, but will return null.
how
)

Utility method for traversing a single node when we know a-priori that the node if fully selected.

private Node

Returns:

Returns a node that is the result of visiting nodes. If the traversal operation is DELETE_CONTENTS the return value is null.
traverseLeftBoundary
(Node
The node that is the root of the "left boundary" subtree.
root
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a node containing the boundaries content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will produced cloned content.
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes within the boundary.
how
)

Traverses the "left boundary" of this range and operates on each "boundary node" according to the how parameter.

private Node

Returns:

Returns a node that is the result of visiting the node. If the traversal operation is DELETE_CONTENTS the return value is null.
traverseNode
(Node
The node to be traversed.
n
,
boolean
Set to true if the node is fully selected. Should be false otherwise. Note that although the DOM 2 specification says that a text node that is boththe start and end container is not selected, we treat it here as if it were partially selected.
isFullySelected
,
boolean
Is true if we are traversing the node as part of navigating the "left boundary" of the range. If this value is false, it implies we are navigating the "right boundary" of the range.
isLeft
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will simply return the original node.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will return a cloned node.
  3. DELETE_CONTENTS - will delete the node from it's parent, but will return null.
how
)

Utility method for traversing a single node.

private Node

Returns:

Returns a node that is the result of visiting the node. If the traversal operation is DELETE_CONTENTS the return value is null.
traversePartiallySelected
(Node
The node to be traversed.
n
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will simply return the original node.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will return a cloned node.
  3. DELETE_CONTENTS - will delete the node from it's parent, but will return null.
how
)

Utility method for traversing a single node when we know a-priori that the node if partially selected and is not a text node.

private Node

Returns:

Returns a node that is the result of visiting nodes. If the traversal operation is DELETE_CONTENTS the return value is null.
traverseRightBoundary
(Node
The node that is the root of the "right boundary" subtree.
root
,
int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a node containing the boundaries content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but will produced cloned content.
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes within the boundary.
how
)

Traverses the "right boundary" of this range and operates on each "boundary node" according to the how parameter.

private DocumentFragment

Returns:

Returns a document fragment containing any copied or extracted nodes. If the how parameter was DELETE_CONTENTS, the return value is null.
traverseSameContainer
(int
Specifies what type of traversal is being requested (extract, clone, or delete). Legal values for this argument are:
  1. EXTRACT_CONTENTS - will produce a document fragment containing the range's content. Partially selected nodes are copied, but fully selected nodes are moved.
  2. CLONE_CONTENTS - will leave the context tree of the range undisturbed, but sill produced cloned content in a document fragment
  3. DELETE_CONTENTS - will delete from the context tree of the range, all fully selected nodes.
how
)

Visits the nodes selected by this range when we know a-priori that the start and end containers are the same.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait