KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > expr > EmptyNodeSet


1 package com.icl.saxon.expr;
2 import com.icl.saxon.*;
3 import com.icl.saxon.om.*;
4
5 /**
6 * A node-set value no nodes
7 */

8
9 public final class EmptyNodeSet extends NodeSetValue {
10
11     private static NodeInfo[] emptyArray = new NodeInfo[0];
12
13     /**
14     * Evaluate the Node Set. This guarantees to return the result in sorted order.
15     * @param context The context for evaluation (not used)
16     */

17
18     public Value evaluate(Context context) {
19         return this;
20     }
21     
22     /**
23     * Evaluate an expression as a NodeSet.
24     * @param context The context in which the expression is to be evaluated
25     * @return the value of the expression, evaluated in the current context
26     */

27
28     public NodeSetValue evaluateAsNodeSet(Context context) {
29         return this;
30     }
31
32     /**
33     * Set a flag to indicate whether the nodes are sorted. Used when the creator of the
34     * node-set knows that they are already in document order.
35     * @param isSorted true if the caller wishes to assert that the nodes are in document order
36     * and do not need to be further sorted
37     */

38
39     public void setSorted(boolean isSorted) {}
40     
41     /**
42     * Test whether the value is known to be sorted
43     * @return true if the value is known to be sorted in document order, false if it is not
44     * known whether it is sorted.
45     */

46
47     public boolean isSorted() {
48         return true;
49     }
50
51     /**
52     * Determine, in the case of an expression whose data type is Value.NODESET,
53     * whether all the nodes in the node-set are guaranteed to come from the same
54     * document as the context node. Used for optimization.
55     */

56     
57     public boolean isContextDocumentNodeSet() {
58         return true;
59     }
60     
61     /**
62     * Convert to string value
63     * @return an empty string
64     */

65
66     public String JavaDoc asString() {
67         return "";
68     }
69
70     /**
71     * Evaluate as a boolean.
72     * @return false
73     */

74
75     public boolean asBoolean() {
76         return false;
77     }
78
79     /**
80     * Count the nodes in the node-set.
81     * @return zero
82     */

83
84     public int getCount() {
85         return 0;
86     }
87
88
89     /**
90     * Sort the nodes into document order.
91     * This does nothing if the nodes are already known to be sorted; to force a sort,
92     * call setSorted(false)
93     * @return the same NodeSetValue, after sorting. (Historic)
94     */

95
96     public NodeSetValue sort() {
97         return this;
98     }
99     
100     /**
101     * Get the first node in the nodeset (in document order)
102     * @return null
103     */

104
105     public NodeInfo getFirst() {
106         return null;
107     }
108         
109
110     /**
111     * Test whether this nodeset "equals" another Value
112     */

113
114     public boolean equals(Value other) {
115         if (other instanceof BooleanValue) {
116             return !((BooleanValue)other).asBoolean();
117         } else {
118             return false;
119         }
120     }
121
122     /**
123     * Test whether this nodeset "not-equals" another Value
124     */

125
126     public boolean notEquals(Value other) {
127         if (other instanceof BooleanValue) {
128             return ((BooleanValue)other).asBoolean();
129         } else {
130             return false;
131         }
132     }
133
134     /**
135     * Return an enumeration of this nodeset value.
136     */

137
138     public NodeEnumeration enumerate() {
139         return EmptyEnumeration.getInstance();
140     }
141
142 }
143
144 //
145
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
146
// you may not use this file except in compliance with the License. You may obtain a copy of the
147
// License at http://www.mozilla.org/MPL/
148
//
149
// Software distributed under the License is distributed on an "AS IS" basis,
150
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
151
// See the License for the specific language governing rights and limitations under the License.
152
//
153
// The Original Code is: all this file.
154
//
155
// The Initial Developer of the Original Code is
156
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
157
//
158
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
159
//
160
// Contributor(s): none.
161
//
162

163
Popular Tags