KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.tree;
2 import com.icl.saxon.pattern.NodeTest;
3
4 final class DescendantEnumeration extends TreeEnumeration {
5
6     private NodeImpl root;
7     private boolean includeSelf;
8
9     public DescendantEnumeration(NodeImpl node, NodeTest nodeTest, boolean includeSelf) {
10         super(node, nodeTest);
11         root = node;
12         this.includeSelf = includeSelf;
13         if (!includeSelf || !conforms(node)) {
14             advance();
15         }
16     }
17
18     public boolean isSorted() {
19         return true;
20     }
21
22     protected void step() {
23         next = next.getNextInDocument(root);
24     }
25
26     /**
27     * Get the last position, that is the number of nodes in the enumeration
28     */

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