KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > tree > FollowingEnumeration


1 package com.icl.saxon.tree;
2 import com.icl.saxon.om.NodeInfo;
3 import com.icl.saxon.pattern.NodeTest;
4
5 final class FollowingEnumeration extends TreeEnumeration {
6     
7     private NodeImpl root;
8     
9     public FollowingEnumeration(NodeImpl node, NodeTest nodeTest) {
10         super(node, nodeTest);
11         root = (DocumentImpl)node.getDocumentRoot();
12         // skip the descendant nodes if any
13
short type = node.getNodeType();
14         if (type==NodeInfo.ATTRIBUTE || type==NodeInfo.NAMESPACE) {
15             next = ((NodeImpl)node.getParentNode()).getNextInDocument(root);
16         } else {
17             do {
18                 next = (NodeImpl)node.getNextSibling();
19                 if (next==null) node = (NodeImpl)node.getParentNode();
20             } while (next==null && node!=null);
21         }
22         while (!conforms(next)) {
23             step();
24         }
25     }
26
27     protected void step() {
28         next = next.getNextInDocument(root);
29     }
30
31     public boolean isSorted() {
32         return true;
33     }
34
35     /**
36     * Get the last position, that is the number of nodes in the enumeration
37     */

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