KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > om > SingletonEnumeration


1 package com.icl.saxon.om;
2
3 /**
4 * SingletonEnumeration: an enumeration of zero or one nodes
5 */

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