com.xpn.xwiki.wysiwyg.client.selection
Interface Range

All Known Implementing Classes:
AbstractRange, DefaultRange, IERange

public interface Range

The Range object represents a fragment of a document that can contain nodes and parts of text nodes in a given document.


Method Summary
 DocumentFragment cloneContents()
          Duplicates the contents of a Range.
 Range cloneRange()
          Produces a new Range whose boundary-points are equal to the boundary-points of the Range.
 void collapse(boolean toStart)
          Collapse a Range onto one of its boundary-points.
 short compareBoundaryPoints(RangeCompare how, Range sourceRange)
          Compare the boundary-points of two Ranges in a document.
 void deleteContents()
          Removes the contents of a Range from the containing document or document fragment without returning a reference to the removed content.
 void detach()
          Called to indicate that the Range is no longer in use and that the implementation may relinquish any resources associated with this Range.
 DocumentFragment extractContents()
          Moves the contents of a Range from the containing document or document fragment to a new DocumentFragment.
 com.google.gwt.dom.client.Node getCommonAncestorContainer()
           
 com.google.gwt.dom.client.Node getEndContainer()
           
 int getEndOffset()
           
 com.google.gwt.dom.client.Node getStartContainer()
           
 int getStartOffset()
           
 void insertNode(com.google.gwt.dom.client.Node newNode)
          Inserts a node into the Document or DocumentFragment at the start of the Range.
 boolean isCollapsed()
           
 void selectNode(com.google.gwt.dom.client.Node refNode)
          Select a node and its contents.
 void selectNodeContents(com.google.gwt.dom.client.Node refNode)
          Select the contents within a node.
 void setEnd(com.google.gwt.dom.client.Node refNode, int offset)
          Sets the attributes describing the end of a Range.
 void setEndAfter(com.google.gwt.dom.client.Node refNode)
          Sets the end of a Range to be after a node.
 void setEndBefore(com.google.gwt.dom.client.Node refNode)
          Sets the end position to be before a node.
 void setStart(com.google.gwt.dom.client.Node refNode, int offset)
          Sets the attributes describing the start of the Range.
 void setStartAfter(com.google.gwt.dom.client.Node refNode)
          Sets the start position to be after a node.
 void setStartBefore(com.google.gwt.dom.client.Node refNode)
          Sets the start position to be before a node.
 void surroundContents(com.google.gwt.dom.client.Node newParent)
          Re-parents the contents of the Range to the given node and inserts the node at the position of the start of the Range.
 java.lang.String toString()
          Returns the contents of a Range as a string.
 

Method Detail

getStartContainer

com.google.gwt.dom.client.Node getStartContainer()
Returns:
Node within which the Range begins.

getStartOffset

int getStartOffset()
Returns:
Offset within the starting node of the Range.

getEndContainer

com.google.gwt.dom.client.Node getEndContainer()
Returns:
Node within which the Range ends.

getEndOffset

int getEndOffset()
Returns:
Offset within the ending node of the Range.

isCollapsed

boolean isCollapsed()
Returns:
true if the Range is collapsed.

getCommonAncestorContainer

com.google.gwt.dom.client.Node getCommonAncestorContainer()
Returns:
The deepest common ancestor container of the Range's two boundary-points.

setStart

void setStart(com.google.gwt.dom.client.Node refNode,
              int offset)
Sets the attributes describing the start of the Range.

Parameters:
refNode - The refNode value. This parameter must be different from null.
offset - The startOffset value.

setEnd

void setEnd(com.google.gwt.dom.client.Node refNode,
            int offset)
Sets the attributes describing the end of a Range.

Parameters:
refNode - The refNode value. This parameter must be different from null.
offset - The endOffset value.

setStartBefore

void setStartBefore(com.google.gwt.dom.client.Node refNode)
Sets the start position to be before a node.

Parameters:
refNode - Range starts before refNode.

setStartAfter

void setStartAfter(com.google.gwt.dom.client.Node refNode)
Sets the start position to be after a node.

Parameters:
refNode - Range starts after refNode.

setEndBefore

void setEndBefore(com.google.gwt.dom.client.Node refNode)
Sets the end position to be before a node.

Parameters:
refNode - Range ends before refNode.

setEndAfter

void setEndAfter(com.google.gwt.dom.client.Node refNode)
Sets the end of a Range to be after a node.

Parameters:
refNode - Range ends after refNode.

collapse

void collapse(boolean toStart)
Collapse a Range onto one of its boundary-points.

Parameters:
toStart - If true, collapses the Range onto its start; if false, collapses it onto its end.

selectNode

void selectNode(com.google.gwt.dom.client.Node refNode)
Select a node and its contents.

Parameters:
refNode - The node to select.

selectNodeContents

void selectNodeContents(com.google.gwt.dom.client.Node refNode)
Select the contents within a node.

Parameters:
refNode - Node to select from.

compareBoundaryPoints

short compareBoundaryPoints(RangeCompare how,
                            Range sourceRange)
Compare the boundary-points of two Ranges in a document.

Parameters:
how - The type of comparison.
sourceRange - The Range on which this current Range is compared to.
Returns:
-1, 0 or 1 depending on whether the corresponding boundary-point of the Range is respectively before, equal to, or after the corresponding boundary-point of sourceRange.

deleteContents

void deleteContents()
Removes the contents of a Range from the containing document or document fragment without returning a reference to the removed content.


extractContents

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

Returns:
A DocumentFragment containing the extracted contents.

cloneContents

DocumentFragment cloneContents()
Duplicates the contents of a Range.

Returns:
A DocumentFragment that contains content equivalent to this Range.

insertNode

void insertNode(com.google.gwt.dom.client.Node newNode)
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.

surroundContents

void surroundContents(com.google.gwt.dom.client.Node newParent)
Re-parents 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.

cloneRange

Range cloneRange()
Produces a new Range whose boundary-points are equal to the boundary-points of the Range.

Returns:
The duplicated Range.

toString

java.lang.String toString()
Returns the contents of a Range as a string. This string contains only the data characters, not any mark-up.

Overrides:
toString in class java.lang.Object
Returns:
The contents of the Range.

detach

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



Copyright © 2004-2008 XWiki. All Rights Reserved.