KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.tree;
2 import com.icl.saxon.pattern.NodeTest;
3
4 final class PrecedingOrAncestorEnumeration extends TreeEnumeration {
5
6     /**
7     * This axis cannot be requested directly in an XPath expression
8     * but is used when evaluating xsl:number. It is provided because
9     * taking the union of the two axes would be very inefficient
10     */

11
12    
13     public PrecedingOrAncestorEnumeration(NodeImpl node, NodeTest nodeTest) {
14         super(node, nodeTest);
15         advance();
16     }
17
18     protected void step() {
19         next = next.getPreviousInDocument();
20     }
21
22     /**
23     * Get the last position, that is the number of nodes in the enumeration
24     */

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