/** * Return the first child Node from the current node, after applying filter, * whatToshow. If result is not null, set the current Node. */ public Node firstChild() { if (currentNode == null) return null; Node node = getFirstChild(currentNode); if (node != null) currentNode = node; return node; }
/** * Return the last child Node from the current node, after applying filter, * whatToshow. If result is not null, set the current Node. */ public Node lastChild() { if (currentNode == null) return null; Node node = getLastChild(currentNode); if (node != null) currentNode = node; return node; }
/** * Return the next sibling Node from the current node, after applying * filter, whatToshow. If result is not null, set the current Node. */ public Node nextSibling() { if (currentNode == null) return null; Node node = getNextSibling(currentNode); if (node != null) currentNode = node; return node; }
/** * Internal function. Return the previous sibling Node, from the input node * after applying filter, whatToshow. The current node is not consulted or * set. */ private Node getPreviousSibling(Node node) { if (node == null || node == root) return null; Node newNode = node.getPreviousSibling(); if (newNode == null) { newNode = node.getParentNode(); if (newNode == null || node == root) return null; int parentAccept = acceptNode(newNode); if (parentAccept == NodeFilter.FILTER_SKIP) return getPreviousSibling(newNode); return null; } int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else if (accept == NodeFilter.FILTER_SKIP) { Node fChild = getLastChild(newNode); if (fChild == null) return getPreviousSibling(newNode); return fChild; } else // if (accept == NodeFilter.REJECT_NODE) return getPreviousSibling(newNode); }
/** * Internal function. Return the first child Node, from the input node after * applying filter, whatToshow. The current node is not consulted or set. */ private Node getFirstChild(Node node) { if (node == null) return null; Node newNode = node.getFirstChild(); if (newNode == null) return null; int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else if (accept == NodeFilter.FILTER_SKIP && newNode.hasChildNodes()) return getFirstChild(newNode); // if (accept == NodeFilter.REJECT_NODE) return getNextSibling(newNode); }
return null; Node result = getFirstChild(currentNode); result = getNextSibling(currentNode); Node parent = getParentNode(currentNode); while (parent != null) { result = getNextSibling(parent); if (result != null) { currentNode = result; return result; } else { parent = getParentNode(parent);
Node result = getPreviousSibling(currentNode); if (result == null) { result = getParentNode(currentNode); if (result != null) { currentNode = result; Node lastChild = getLastChild(result); lastChild = getLastChild(prev);
/** * Internal function. Return the parent Node, from the input node after * applying filter, whatToshow. The current node is not consulted or set. */ private Node getParentNode(Node node) { if (node == null || node == root) return null; Node newNode = node.getParentNode(); if (newNode == null) return null; int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else // if (accept == NodeFilter.SKIP_NODE) // and REJECT too. return getParentNode(newNode); }
public Traversal(Document doc, Object source, int whatToShow) { this.walker = new GenericTreeWalker(doc.getDocumentElement(), whatToShow); this.source = source; }
/** * Return the parent Node from the current node, after applying filter, * whatToshow. If result is not null, set the current Node. */ public Node parentNode() { if (currentNode == null) return null; Node node = getParentNode(currentNode); if (node != null) currentNode = node; return node; }
/** * Return the previous sibling Node from the current node, after applying * filter, whatToshow. If result is not null, set the current Node. */ public Node previousSibling() { if (currentNode == null) return null; Node node = getPreviousSibling(currentNode); if (node != null) currentNode = node; return node; }
/** * Internal function. Return the previous sibling Node, from the input node * after applying filter, whatToshow. The current node is not consulted or * set. */ private Node getPreviousSibling(Node node) { if (node == null || node == root) return null; Node newNode = node.getPreviousSibling(); if (newNode == null) { newNode = node.getParentNode(); if (newNode == null || node == root) return null; int parentAccept = acceptNode(newNode); if (parentAccept == NodeFilter.FILTER_SKIP) return getPreviousSibling(newNode); return null; } int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else if (accept == NodeFilter.FILTER_SKIP) { Node fChild = getLastChild(newNode); if (fChild == null) return getPreviousSibling(newNode); return fChild; } else // if (accept == NodeFilter.REJECT_NODE) return getPreviousSibling(newNode); }
/** * Internal function. Return the first child Node, from the input node after * applying filter, whatToshow. The current node is not consulted or set. */ private Node getFirstChild(Node node) { if (node == null) return null; Node newNode = node.getFirstChild(); if (newNode == null) return null; int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else if (accept == NodeFilter.FILTER_SKIP && newNode.hasChildNodes()) return getFirstChild(newNode); // if (accept == NodeFilter.REJECT_NODE) return getNextSibling(newNode); }
return null; Node result = getFirstChild(currentNode); result = getNextSibling(currentNode); Node parent = getParentNode(currentNode); while (parent != null) { result = getNextSibling(parent); if (result != null) { currentNode = result; return result; } else { parent = getParentNode(parent);
Node result = getPreviousSibling(currentNode); if (result == null) { result = getParentNode(currentNode); if (result != null) { currentNode = result; Node lastChild = getLastChild(result); lastChild = getLastChild(prev);
/** * Internal function. Return the parent Node, from the input node after * applying filter, whatToshow. The current node is not consulted or set. */ private Node getParentNode(Node node) { if (node == null || node == root) return null; Node newNode = node.getParentNode(); if (newNode == null) return null; int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else // if (accept == NodeFilter.SKIP_NODE) // and REJECT too. return getParentNode(newNode); }
public Traversal(Document doc, Object source, int whatToShow) { this.walker = new GenericTreeWalker(doc.getDocumentElement(), whatToShow); this.source = source; }
/** * Return the parent Node from the current node, after applying filter, * whatToshow. If result is not null, set the current Node. */ public Node parentNode() { if (currentNode == null) return null; Node node = getParentNode(currentNode); if (node != null) currentNode = node; return node; }
/** * Return the previous sibling Node from the current node, after applying * filter, whatToshow. If result is not null, set the current Node. */ public Node previousSibling() { if (currentNode == null) return null; Node node = getPreviousSibling(currentNode); if (node != null) currentNode = node; return node; }
/** * Internal function. Return the previous sibling Node, from the input node * after applying filter, whatToshow. The current node is not consulted or * set. */ private Node getPreviousSibling(Node node) { if (node == null || node == root) return null; Node newNode = node.getPreviousSibling(); if (newNode == null) { newNode = node.getParentNode(); if (newNode == null || node == root) return null; int parentAccept = acceptNode(newNode); if (parentAccept == NodeFilter.FILTER_SKIP) return getPreviousSibling(newNode); return null; } int accept = acceptNode(newNode); if (accept == NodeFilter.FILTER_ACCEPT) return newNode; else if (accept == NodeFilter.FILTER_SKIP) { Node fChild = getLastChild(newNode); if (fChild == null) return getPreviousSibling(newNode); return fChild; } else // if (accept == NodeFilter.REJECT_NODE) return getPreviousSibling(newNode); }