textbender.g.xml.dom
Class DOMPointer

java.lang.Object
  extended by DOMPointer

public final class DOMPointer
extends Object

A pointer into a node. Points to a node, and an offset within it.

Cf. DOM Traversal and Range, and org.w3c.dom.ranges.Range.


Field Summary
 Node node
          The node pointed at.
 int offset
          The offset pointed at, within the node.
 
Constructor Summary
DOMPointer()
          Creates a DOMPointer with an initial node of null.
 
Method Summary
 boolean equals(Object o)
          Returns true iff o is a DOMPointer, and points to an 'equals' node and offset.
 DOMPointer lastTextOffset(Node parent)
          Positions the pointer at the last offset among Text children of the specified parent.
 DOMPointer lastTextOffsetOrNode(Node parent)
          Positions the pointer at the last offset among Text children of the specified parent, or the last non-Text child, whichever comes later.
 DOMPointer nextTextOffset()
          Moves this pointer forward to the next Text offset among sibling nodes.
 DOMPointer nextTextOffsetOrNode()
          Moves this pointer forward to the next Text offset, or the next non-Text sibling node, whichever comes first.
 DOMPointer previousTextOffset()
          Moves this pointer back to the previous Text offset among sibling nodes.
 DOMPointer previousTextOffsetOrNode()
          Moves this pointer back to the previous Text offset, or the previous non-Text sibling node, whichever comes first.
 DOMPointer set(Node node, int offset)
           
 DOMPointer setFrom(DOMPointer other)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

public Node node
The node pointed at.


offset

public int offset
The offset pointed at, within the node. For character based nodes, this is a character offset; for other nodes, a child offset.

Constructor Detail

DOMPointer

public DOMPointer()
Creates a DOMPointer with an initial node of null.

Method Detail

lastTextOffset

public DOMPointer lastTextOffset(Node parent)
Positions the pointer at the last offset among Text children of the specified parent. If no such offset exists, node is set to null, and offset to -1.

Returns:
reference to this pointer

lastTextOffsetOrNode

public DOMPointer lastTextOffsetOrNode(Node parent)
Positions the pointer at the last offset among Text children of the specified parent, or the last non-Text child, whichever comes later. If the resulting node is non-Text or null, offset is set to -1.

Returns:
reference to this pointer

nextTextOffset

public DOMPointer nextTextOffset()
Moves this pointer forward to the next Text offset among sibling nodes. All non-Text nodes are skipped. If no such offset exists, node is set to null, and offset to -1.

Returns:
reference to this pointer

nextTextOffsetOrNode

public DOMPointer nextTextOffsetOrNode()
Moves this pointer forward to the next Text offset, or the next non-Text sibling node, whichever comes first. If the resulting node is non-Text or null, offset is set to -1.

Returns:
reference to this pointer

previousTextOffset

public DOMPointer previousTextOffset()
Moves this pointer back to the previous Text offset among sibling nodes. All non-Text nodes are skipped. If no such offset exists, node is set to null, and offset to -1.

Returns:
reference to this pointer

previousTextOffsetOrNode

public DOMPointer previousTextOffsetOrNode()
Moves this pointer back to the previous Text offset, or the previous non-Text sibling node, whichever comes first. If the resulting node is non-Text or null, offset is set to -1.

Returns:
reference to this pointer

set

public DOMPointer set(Node node,
                      int offset)
Parameters:
node - per node
offset - per offset
Returns:
reference to this pointer

setFrom

public DOMPointer setFrom(DOMPointer other)
Parameters:
other - pointer, whose node and offset to assign to this pointer
Returns:
reference to this pointer

equals

public boolean equals(Object o)
Returns true iff o is a DOMPointer, and points to an 'equals' node and offset.

Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object