org.apache.pivot.wtk.text
Class Node

java.lang.Object
  extended by org.apache.pivot.wtk.text.Node
Direct Known Subclasses:
Element, ImageNode, TextNode

public abstract class Node
extends Object

Abstract base class for document nodes.


Constructor Summary
Node()
           
 
Method Summary
abstract  Node duplicate(boolean recursive)
          Creates a copy of this node.
abstract  int getCharacterCount()
          Returns the number of characters in this node.
 int getDocumentOffset()
          Returns the node's offset within the document.
 ListenerList<NodeListener> getNodeListeners()
          Returns the node listener list.
 int getOffset()
          Returns the node's offset within its parent.
 Element getParent()
          Returns the parent element of this node.
abstract  Node getRange(int offset, int characterCount)
          Returns a range from the node.
abstract  void insertRange(Node range, int offset)
          Inserts a range into the node.
protected  void rangeInserted(int offset, int characterCount)
          Called to notify a node that a range has been inserted.
protected  void rangeRemoved(int offset, int characterCount)
          Called to notify a node that a range has been removed.
abstract  Node removeRange(int offset, int characterCount)
          Removes a range from the node.
 Node replaceRange(int offset, int characterCount, Node range)
          Replaces an existing range with a new range.
protected  void setOffset(int offset)
           
protected  void setParent(Element parent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

getParent

public Element getParent()
Returns the parent element of this node.

Returns:
The node's parent, or null if the node does not have a parent.

setParent

protected void setParent(Element parent)

getOffset

public int getOffset()
Returns the node's offset within its parent.

Returns:
The integer offset of the node's first character within its parent element.

setOffset

protected void setOffset(int offset)

getDocumentOffset

public int getDocumentOffset()
Returns the node's offset within the document.


insertRange

public abstract void insertRange(Node range,
                                 int offset)
Inserts a range into the node. Note that the contents of the range, rather than the range itself, is added to the node.

Parameters:
range -
offset -

removeRange

public abstract Node removeRange(int offset,
                                 int characterCount)
Removes a range from the node.

Parameters:
offset -
characterCount -
Returns:
The removed range. This will be a copy of the node structure relative to this node.

replaceRange

public Node replaceRange(int offset,
                         int characterCount,
                         Node range)
Replaces an existing range with a new range.

Parameters:
offset -
characterCount -
range -
Returns:
The removed range. This will be a copy of the node structure relative to this node.

getRange

public abstract Node getRange(int offset,
                              int characterCount)
Returns a range from the node.

Parameters:
offset -
characterCount -
Returns:
A node containing a copy of the node structure spanning the given range, relative to this node.

getCharacterCount

public abstract int getCharacterCount()
Returns the number of characters in this node.


duplicate

public abstract Node duplicate(boolean recursive)
Creates a copy of this node.

Parameters:
recursive -

rangeInserted

protected void rangeInserted(int offset,
                             int characterCount)
Called to notify a node that a range has been inserted.

Parameters:
offset -
characterCount -

rangeRemoved

protected void rangeRemoved(int offset,
                            int characterCount)
Called to notify a node that a range has been removed.

Parameters:
offset -
characterCount -

getNodeListeners

public ListenerList<NodeListener> getNodeListeners()
Returns the node listener list.