textbender.g.xml.dom
Class NodeX

java.lang.Object
  extended by NodeX

public final class NodeX
extends Object

Node utilities.


Method Summary
static void _testWalk(Node node)
          Test code.
static boolean areAncestorAndDescendant(Node a, Node d)
          Answers whether one node (a) is an ancestor of another (d); or equivalently whether d is a descendant of a.
static ProcessingInstruction findChildProcessingInstruction(Node parent, String target)
          Returns the named processing instruction, if one exists as a child of the parent node.
static int indexIn(Node parent, Node child)
          Returns the index of the specified child in the parent node.
static void moveElementsNS(Node fromParent, String namespaceURI, String localName, Node toParent)
          Removes from 'fromParent' all child elements of the specified name, and appends them to 'toParent'.
static Node nextNode(Node node)
          Returns the next node, in document order.
static Node nextNode(Node node, boolean deeply)
          Returns the next node, in document order.
static boolean nullSame(Node n1, Node n2)
          Returns true iff the nodes are either the 'same nodes', or both null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findChildProcessingInstruction

public static ProcessingInstruction findChildProcessingInstruction(Node parent,
                                                                   String target)
Returns the named processing instruction, if one exists as a child of the parent node.

Parameters:
parent - to search
target - name of processing instruction
Returns:
named processing instruction, or null if none exists as a child of the parent node

areAncestorAndDescendant

public static boolean areAncestorAndDescendant(Node a,
                                               Node d)
Answers whether one node (a) is an ancestor of another (d); or equivalently whether d is a descendant of a.

Returns:
true iff a has descendant d

indexIn

public static int indexIn(Node parent,
                          Node child)
Returns the index of the specified child in the parent node.

Returns:
index, or -1 if parent has no such child

moveElementsNS

public static void moveElementsNS(Node fromParent,
                                  String namespaceURI,
                                  String localName,
                                  Node toParent)
Removes from 'fromParent' all child elements of the specified name, and appends them to 'toParent'.


nextNode

public static Node nextNode(Node node)
Returns the next node, in document order. Equivalent to nextNode(node,true) and org.w3c.dom.traversal.TreeWalker.nextNode().

Parameters:
node - reference node, which may be null
Returns:
next node; or null if reference node is null, or document has no more nodes

nextNode

public static Node nextNode(Node node,
                            boolean deeply)
Returns the next node, in document order. nextNode(node,true) is equivalent to org.w3c.dom.traversal.TreeWalker.nextNode().

Parameters:
node - reference node, which may be null
deeply - if true, return the first child node (if any)
Returns:
next node; or null if reference node is null, or document has no more nodes

nullSame

public static boolean nullSame(Node n1,
                               Node n2)
Returns true iff the nodes are either the 'same nodes', or both null.


_testWalk

public static void _testWalk(Node node)
Test code.