Debian Codegraph @

net/sf/saxon/tree/linked/FollowingEnumeration.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.tree.linked;
9
10 import net.sf.saxon.pattern.NodeTest;
11 import net.sf.saxon.type.Type;
12
13 final class FollowingEnumeration extends TreeEnumeration {
14
15 private NodeImpl root;
16
17 public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) {
18 super(node, nodeTest);
19 root = (NodeImpl)node.getRoot();
20 // skip the descendant nodes if any
21 int type = node.getNodeKind();
22 if (type == Type.ATTRIBUTE || type == Type.NAMESPACE) {
23 next = node.getParent().getNextInDocument(root);
24 } else {
25 do {
26 next = node.getNextSibling();
27 if (next == null) {
28 node = node.getParent();
29 }
30 } while (next == null && node != null);
31 }
32 while (!conforms(next)) {
33 step();
34 }
35 }
36
37 protected void step() {
38 next = next.getNextInDocument(root);
39 }
40
41 }
42