KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > tree > FollowingEnumeration


1 package net.sf.saxon.tree;
2 import net.sf.saxon.om.SequenceIterator;
3 import net.sf.saxon.pattern.NodeTest;
4 import net.sf.saxon.type.Type;
5
6 final class FollowingEnumeration extends TreeEnumeration {
7
8     private NodeImpl root;
9
10     public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) {
11         super(node, nodeTest);
12         root = (DocumentImpl)node.getDocumentRoot();
13         // skip the descendant nodes if any
14
int type = node.getNodeKind();
15         if (type==Type.ATTRIBUTE || type==Type.NAMESPACE) {
16             next = ((NodeImpl)node.getParent()).getNextInDocument(root);
17         } else {
18             do {
19                 next = (NodeImpl)node.getNextSibling();
20                 if (next==null) node = (NodeImpl)node.getParent();
21             } while (next==null && node!=null);
22         }
23         while (!conforms(next)) {
24             step();
25         }
26     }
27
28     protected void step() {
29         next = next.getNextInDocument(root);
30     }
31
32     /**
33     * Get another enumeration of the same nodes
34     */

35
36     public SequenceIterator getAnother() {
37         return new FollowingEnumeration(start, nodeTest);
38     }
39
40 }
41
42
43 //
44
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
45
// you may not use this file except in compliance with the License. You may obtain a copy of the
46
// License at http://www.mozilla.org/MPL/
47
//
48
// Software distributed under the License is distributed on an "AS IS" basis,
49
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
50
// See the License for the specific language governing rights and limitations under the License.
51
//
52
// The Original Code is: all this file.
53
//
54
// The Initial Developer of the Original Code is Michael H. Kay.
55
//
56
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
57
//
58
// Contributor(s): none.
59
//
60
Popular Tags