ASF Bugzilla – Attachment 251 Details for
Bug 1541
TreeWalker with sparse filter works in exponential time
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to resolve problems illustrated by TestWalker.java
treewalker.patch (text/plain), 5.51 KB, created by
Dean Brettle
on 2001-06-22 11:27:44 UTC
(
hide
)
Description:
Patch to resolve problems illustrated by TestWalker.java
Filename:
MIME Type:
Creator:
Dean Brettle
Created:
2001-06-22 11:27:44 UTC
Size:
5.51 KB
patch
obsolete
>Index: src/org/apache/xerces/dom/TreeWalkerImpl.java >=================================================================== >RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/dom/TreeWalkerImpl.java,v >retrieving revision 1.3 >diff -d -u -r1.3 TreeWalkerImpl.java >--- src/org/apache/xerces/dom/TreeWalkerImpl.java 2001/06/19 16:54:15 1.3 >+++ src/org/apache/xerces/dom/TreeWalkerImpl.java 2001/06/22 18:25:57 >@@ -319,20 +319,30 @@ > * The current node is not consulted or set. > */ > Node getNextSibling(Node node) { >+ return getNextSibling(node, fRoot); >+ } >+ >+ /** 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. >+ */ >+ Node getNextSibling(Node node, Node root) { > >- if (node == null || node == fRoot) return null; >+ if (node == null || node == root) return null; > > Node newNode = node.getNextSibling(); > if (newNode == null) { > > newNode = node.getParentNode(); > >- if (newNode == null || node == fRoot) return null; >+ if (newNode == null || newNode == root) return null; > > int parentAccept = acceptNode(newNode); > > if (parentAccept==NodeFilter.FILTER_SKIP) { >- return getNextSibling(newNode); >+ return getNextSibling(newNode, root); > } > > return null; >@@ -344,12 +354,16 @@ > return newNode; > else > if (accept == NodeFilter.FILTER_SKIP) { >- return getFirstChild(newNode); >+ Node fChild = getFirstChild(newNode); >+ if (fChild == null) { >+ return getNextSibling(newNode, root); >+ } >+ return fChild; > } > else > //if (accept == NodeFilter.REJECT_NODE) > { >- return getNextSibling(newNode); >+ return getNextSibling(newNode, root); > } > > } // getNextSibling(Node node) { >@@ -360,19 +374,29 @@ > * The current node is not consulted or set. > */ > Node getPreviousSibling(Node node) { >+ return getPreviousSibling(node, fRoot); >+ } >+ >+ /** 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. >+ */ >+ Node getPreviousSibling(Node node, Node root) { > >- if (node == null || node == fRoot) return null; >+ if (node == null || node == root) return null; > > Node newNode = node.getPreviousSibling(); > if (newNode == null) { > > newNode = node.getParentNode(); >- if (newNode == null || node == fRoot) return null; >+ if (newNode == null || newNode == root) return null; > > int parentAccept = acceptNode(newNode); > > if (parentAccept==NodeFilter.FILTER_SKIP) { >- return getPreviousSibling(newNode); >+ return getPreviousSibling(newNode, root); > } > > return null; >@@ -386,14 +410,14 @@ > if (accept == NodeFilter.FILTER_SKIP) { > Node fChild = getLastChild(newNode); > if (fChild == null) { >- return getPreviousSibling(newNode); >+ return getPreviousSibling(newNode, root); > } > return fChild; > } > else > //if (accept == NodeFilter.REJECT_NODE) > { >- return getPreviousSibling(newNode); >+ return getPreviousSibling(newNode, root); > } > > } // getPreviousSibling(Node node) { >@@ -404,15 +428,14 @@ > * The current node is not consulted or set. > */ > Node getFirstChild(Node node) { >- > if (node == null) return null; > > if ( !fEntityReferenceExpansion > && node.getNodeType() == Node.ENTITY_REFERENCE_NODE) > return null; >- >+ > Node newNode = node.getFirstChild(); >- if (newNode == null) return getNextSibling(node); >+ if (newNode == null) return null; > > int accept = acceptNode(newNode); > >@@ -422,12 +445,16 @@ > if (accept == NodeFilter.FILTER_SKIP > && newNode.hasChildNodes()) > { >- return getFirstChild(newNode); >+ Node fChild = getFirstChild(newNode); >+ if (fChild == null) { >+ return getNextSibling(newNode, node); >+ } >+ return fChild; > } > else > //if (accept == NodeFilter.REJECT_NODE) > { >- return getNextSibling(newNode); >+ return getNextSibling(newNode, node); > } > > >@@ -457,12 +484,16 @@ > if (accept == NodeFilter.FILTER_SKIP > && newNode.hasChildNodes()) > { >- return getLastChild(newNode); >+ Node lChild = getLastChild(newNode); >+ if (lChild == null) { >+ return getPreviousSibling(newNode, node); >+ } >+ return lChild; > } > else > //if (accept == NodeFilter.REJECT_NODE) > { >- return getPreviousSibling(newNode); >+ return getPreviousSibling(newNode, node); > } > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1541
:
250
| 251