KickJava   Java API By Example, From Geeks To Geeks.

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


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

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