KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.tree;
2 import com.icl.saxon.om.NodeInfo;
3 import com.icl.saxon.om.AxisEnumeration;
4 import com.icl.saxon.expr.LastPositionFinder;
5
6
7 /**
8   * ArrayEnumeration is used to enumerate nodes held in an array.
9   * It is used only to enumerate the children of a node: this is assumed in the
10   * values returned by isSorted(), etc.
11   * @author Michael H. Kay (mhkay@iclway.co.uk)
12   */

13   
14
15 final class ArrayEnumeration implements AxisEnumeration {
16
17     NodeInfo[] nodes;
18     int index = 0;
19
20     public ArrayEnumeration(NodeInfo[] nodes) {
21         this.nodes = nodes;
22         index = 0;
23         for (int i=0; i<nodes.length; i++) {
24             if (nodes[i]==null) {
25                 System.err.println(" node " + i + " is null");
26             }
27         }
28     }
29     
30     public boolean hasMoreElements() {
31         return index < nodes.length;
32     }
33
34     public NodeInfo nextElement() {
35         return nodes[index++];
36     }
37
38     public boolean isSorted() {
39         return true;
40     }
41
42     public boolean isReverseSorted() {
43         return false;
44     }
45
46     public boolean isPeer() {
47         return true;
48     }
49
50     public int getLastPosition() {
51         return nodes.length;
52     }
53 }
54
55
56 //
57
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
58
// you may not use this file except in compliance with the License. You may obtain a copy of the
59
// License at http://www.mozilla.org/MPL/
60
//
61
// Software distributed under the License is distributed on an "AS IS" basis,
62
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
63
// See the License for the specific language governing rights and limitations under the License.
64
//
65
// The Original Code is: all this file.
66
//
67
// The Initial Developer of the Original Code is
68
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
69
//
70
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
71
//
72
// Contributor(s): none.
73
//
74
Popular Tags