org.apache.pivot.wtk.text
Class Node

java.lang.Object
  extended by org.apache.pivot.wtk.text.Node
Direct Known Subclasses:
ComponentNode, 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  char getCharacterAt(int offsetArgument)
          Returns the character at the given offset.
abstract  int getCharacterCount()
          Returns the number of characters in this node.
 int getDocumentOffset()
          Returns the node's offset within the document.
 Span getDocumentSpan()
           
 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 offsetArgument, int characterCount)
          Returns a range from the node.
abstract  void insertRange(Node range, int offsetArgument)
          Inserts a range into the node.
protected  void nodeInserted(int offsetArgument)
          Called to notify a node that a child node has been inserted.
protected  void nodesRemoved(Sequence<Node> removed, int offsetArgument)
          Called to notify a node that some child nodes has been removed.
protected  void rangeInserted(int offsetArgument, int characterCount)
          Called to notify a node that a range has been inserted.
protected  void rangeRemoved(int offsetArgument, int characterCount)
          Called to notify a node that a range has been removed.
abstract  Node removeRange(int offsetArgument, int characterCount)
          Removes a range from the node.
 Node replaceRange(int offsetArgument, 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.


getDocumentSpan

public Span getDocumentSpan()
Returns:
A Span that describes the content range of this node relative to the whole document.

insertRange

public abstract void insertRange(Node range,
                                 int offsetArgument)
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 -
offsetArgument -

removeRange

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

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

replaceRange

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

Parameters:
offsetArgument -
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 offsetArgument,
                              int characterCount)
Returns a range from the node.

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

getCharacterAt

public abstract char getCharacterAt(int offsetArgument)
Returns the character at the given offset.

Parameters:
offsetArgument -

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 offsetArgument,
                             int characterCount)
Called to notify a node that a range has been inserted.

Parameters:
offsetArgument -
characterCount -

rangeRemoved

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

Parameters:
offsetArgument -
characterCount -

nodesRemoved

protected void nodesRemoved(Sequence<Node> removed,
                            int offsetArgument)
Called to notify a node that some child nodes has been removed.

Parameters:
removed -
offsetArgument -

nodeInserted

protected void nodeInserted(int offsetArgument)
Called to notify a node that a child node has been inserted.

Parameters:
offsetArgument -

getNodeListeners

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