Methods Summary |
---|
short | acceptNode(org.w3c.dom.Node node)Internal function.
The node whatToShow and the filter are combined into one result.
/***
7.1.2.4. Filters and whatToShow flags
Iterator and TreeWalker apply whatToShow flags before applying Filters. If a node is rejected by the
active whatToShow flags, a Filter will not be called to evaluate that node. When a node is rejected by
the active whatToShow flags, children of that node will still be considered, and Filters may be called to
evaluate them.
***/
if (fNodeFilter == null) {
if ( ( fWhatToShow & (1 << node.getNodeType()-1)) != 0) {
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
}
} else {
if ((fWhatToShow & (1 << node.getNodeType()-1)) != 0 ) {
return fNodeFilter.acceptNode(node);
} else {
// What to show has failed. See above excerpt from spec.
// Equivalent to FILTER_SKIP.
return NodeFilter.FILTER_SKIP;
}
}
|
public org.w3c.dom.Node | firstChild()Return the first child Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node node = getFirstChild(fCurrentNode);
if (node !=null) {
fCurrentNode = node;
}
return node;
|
public org.w3c.dom.Node | getCurrentNode()Return the current Node.
return fCurrentNode;
|
public boolean | getExpandEntityReferences()Return whether children entity references are included in the iterator.
return fEntityReferenceExpansion;
|
public org.w3c.dom.traversal.NodeFilter | getFilter()Return the NodeFilter
return fNodeFilter;
|
org.w3c.dom.Node | getFirstChild(org.w3c.dom.Node node)Internal function.
Return the first child Node, from the input node
after applying filter, whatToshow.
The current node is not consulted or set.
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
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())
{
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, node);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, node);
}
|
org.w3c.dom.Node | getLastChild(org.w3c.dom.Node node)Internal function.
Return the last child Node, from the input node
after applying filter, whatToshow.
The current node is not consulted or set.
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getLastChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node lChild = getLastChild(newNode);
if (lChild == null) {
return getPreviousSibling(newNode, node);
}
return lChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, node);
}
|
org.w3c.dom.Node | getNextSibling(org.w3c.dom.Node node)Internal function.
Return the nextSibling Node, from the input node
after applying filter, whatToshow.
The current node is not consulted or set.
return getNextSibling(node, fRoot);
|
org.w3c.dom.Node | getNextSibling(org.w3c.dom.Node node, org.w3c.dom.Node root)Internal function.
Return the nextSibling Node, from the input node
after applying filter, whatToshow.
NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
The current node is not consulted or set.
if (node == null || isSameNode(node, root)) return null;
Node newNode = node.getNextSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || isSameNode(newNode, root)) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getNextSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, root);
}
|
org.w3c.dom.Node | getParentNode(org.w3c.dom.Node node)Internal function.
Return the parent Node, from the input node
after applying filter, whatToshow.
The current node is not consulted or set.
if (node == null || isSameNode(node, fRoot)) 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);
}
|
org.w3c.dom.Node | getPreviousSibling(org.w3c.dom.Node node)Internal function.
Return the previous sibling Node, from the input node
after applying filter, whatToshow.
The current node is not consulted or set.
return getPreviousSibling(node, fRoot);
|
org.w3c.dom.Node | getPreviousSibling(org.w3c.dom.Node node, org.w3c.dom.Node root)Internal function.
Return the previousSibling Node, from the input node
after applying filter, whatToshow.
NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
The current node is not consulted or set.
if (node == null || isSameNode(node, root)) return null;
Node newNode = node.getPreviousSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || isSameNode(newNode, root)) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getPreviousSibling(newNode, root);
}
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, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, root);
}
|
public org.w3c.dom.Node | getRoot()
return fRoot;
|
public int | getWhatToShow()Return the whatToShow value
return fWhatToShow;
|
private boolean | isSameNode(org.w3c.dom.Node m, org.w3c.dom.Node n)Returns true if m is the same node n .
return (fUseIsSameNode) ? m.isSameNode(n) : m == n;
|
public org.w3c.dom.Node | lastChild()Return the last child Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node node = getLastChild(fCurrentNode);
if (node !=null) {
fCurrentNode = node;
}
return node;
|
public org.w3c.dom.Node | nextNode()Return the next Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node result = getFirstChild(fCurrentNode);
if (result != null) {
fCurrentNode = result;
return result;
}
result = getNextSibling(fCurrentNode);
if (result != null) {
fCurrentNode = result;
return result;
}
// return parent's 1st sibling.
Node parent = getParentNode(fCurrentNode);
while (parent != null) {
result = getNextSibling(parent);
if (result != null) {
fCurrentNode = result;
return result;
} else {
parent = getParentNode(parent);
}
}
// end , return null
return null;
|
public org.w3c.dom.Node | nextSibling()Return the next sibling Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node node = getNextSibling(fCurrentNode);
if (node !=null) {
fCurrentNode = node;
}
return node;
|
public org.w3c.dom.Node | parentNode()Return the parent Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node node = getParentNode(fCurrentNode);
if (node !=null) {
fCurrentNode = node;
}
return node;
|
public org.w3c.dom.Node | previousNode()Return the previous Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
Node result;
if (fCurrentNode == null) return null;
// get sibling
result = getPreviousSibling(fCurrentNode);
if (result == null) {
result = getParentNode(fCurrentNode);
if (result != null) {
fCurrentNode = result;
return fCurrentNode;
}
return null;
}
// get the lastChild of result.
Node lastChild = getLastChild(result);
Node prev = lastChild ;
while (lastChild != null) {
prev = lastChild ;
lastChild = getLastChild(prev) ;
}
lastChild = prev ;
// if there is a lastChild which passes filters return it.
if (lastChild != null) {
fCurrentNode = lastChild;
return fCurrentNode;
}
// otherwise return the previous sibling.
if (result != null) {
fCurrentNode = result;
return fCurrentNode;
}
// otherwise return null.
return null;
|
public org.w3c.dom.Node | previousSibling()Return the previous sibling Node from the current node,
after applying filter, whatToshow.
If result is not null, set the current Node.
if (fCurrentNode == null) return null;
Node node = getPreviousSibling(fCurrentNode);
if (node !=null) {
fCurrentNode = node;
}
return node;
|
public void | setCurrentNode(org.w3c.dom.Node node)Return the current Node.
if (node == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
fCurrentNode = node;
|
public void | setWhatShow(int whatToShow)
fWhatToShow = whatToShow;
|
private boolean | useIsSameNode(org.w3c.dom.Node node)Use isSameNode() for testing node identity if the DOM implementation
supports DOM Level 3 core and it isn't the Xerces implementation.
if (node instanceof NodeImpl) {
return false;
}
Document doc = node.getNodeType() == Node.DOCUMENT_NODE
? (Document) node : node.getOwnerDocument();
return (doc != null && doc.getImplementation().hasFeature("Core", "3.0"));
|