KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > expr > StaticProperty


1 package net.sf.saxon.expr;
2
3 /**
4 * This class contains constants identifying dependencies that an XPath expression
5 * might have on its context.
6 */

7
8 public abstract class StaticProperty {
9
10     /**
11     * Bit setting: Expression depends on current() item
12     */

13
14     public static final int DEPENDS_ON_CURRENT_ITEM = 1;
15
16     /**
17     * Bit setting: Expression depends on context item
18     */

19
20     public static final int DEPENDS_ON_CONTEXT_ITEM = 1<<1;
21
22     /**
23     * Bit setting: Expression depends on position()
24     */

25
26     public static final int DEPENDS_ON_POSITION = 1<<2;
27
28     /**
29     * Bit setting: Expression depends on last()
30     */

31
32     public static final int DEPENDS_ON_LAST = 1<<3;
33
34     /**
35     * Bit setting: Expression depends on the document containing the context node
36     */

37
38     public static final int DEPENDS_ON_CONTEXT_DOCUMENT = 1<<4;
39
40     /**
41     * Bit setting: Expression depends on current-group() and/or current-grouping-key()
42     */

43
44     public static final int DEPENDS_ON_CURRENT_GROUP = 1<<5;
45
46     /**
47     * Bit setting: Expression depends on regex-group()
48     */

49
50     public static final int DEPENDS_ON_REGEX_GROUP = 1<<6;
51
52
53     /**
54      * Bit setting: Expression depends on local variables
55      */

56
57     public static final int DEPENDS_ON_LOCAL_VARIABLES = 1<<7;
58
59     /**
60      * Bit setting: Expression depends on user-defined functions
61      */

62
63     public static final int DEPENDS_ON_USER_FUNCTIONS = 1<<8;
64
65     /**
66     * Combination of bits representing dependencies on the XSLT context
67     */

68
69     public static final int DEPENDS_ON_XSLT_CONTEXT =
70             DEPENDS_ON_CURRENT_ITEM |
71             DEPENDS_ON_CURRENT_GROUP |
72             DEPENDS_ON_REGEX_GROUP;
73
74     /**
75     * Combination of bits representing dependencies on the focus
76     */

77
78     public static final int DEPENDS_ON_FOCUS =
79             DEPENDS_ON_CONTEXT_ITEM |
80             DEPENDS_ON_POSITION |
81             DEPENDS_ON_LAST |
82             DEPENDS_ON_CONTEXT_DOCUMENT;
83
84     /**
85     * Combination of bits representing dependencies on the focus, but excluding dependencies
86     * on the current document
87     */

88
89     public static final int DEPENDS_ON_NON_DOCUMENT_FOCUS =
90             DEPENDS_ON_CONTEXT_ITEM |
91             DEPENDS_ON_POSITION |
92             DEPENDS_ON_LAST;
93
94     /**
95      * Mask to select all the dependency bits
96      */

97
98     public static final int DEPENDENCY_MASK =
99             DEPENDS_ON_CONTEXT_DOCUMENT |
100             DEPENDS_ON_CONTEXT_ITEM |
101             DEPENDS_ON_CURRENT_GROUP |
102             DEPENDS_ON_REGEX_GROUP |
103             DEPENDS_ON_CURRENT_ITEM |
104             DEPENDS_ON_FOCUS |
105             DEPENDS_ON_LOCAL_VARIABLES |
106             DEPENDS_ON_USER_FUNCTIONS;
107
108     /*
109     * Bit set if an empty sequence is allowed
110     */

111
112     public static final int ALLOWS_ZERO = 1<<13;
113
114     /**
115     * Bit set if a single value is allowed
116     */

117
118     public static final int ALLOWS_ONE = 1<<14;
119
120     /**
121     * Bit set if multiple values are allowed
122     */

123
124     public static final int ALLOWS_MANY = 1<<15;
125
126     /**
127      * Mask for all cardinality bits
128      */

129
130     public static final int CARDINALITY_MASK =
131             ALLOWS_ZERO | ALLOWS_ONE | ALLOWS_MANY;
132
133     /**
134     * Occurence indicator for "one or more" (+)
135     */

136
137     public static final int ALLOWS_ONE_OR_MORE =
138             ALLOWS_ONE | ALLOWS_MANY;
139
140     /**
141     * Occurence indicator for "zero or more" (*)
142     */

143
144     public static final int ALLOWS_ZERO_OR_MORE =
145             ALLOWS_ZERO | ALLOWS_ONE | ALLOWS_MANY;
146
147     /**
148     * Occurence indicator for "zero or one" (?)
149     */

150
151     public static final int ALLOWS_ZERO_OR_ONE =
152             ALLOWS_ZERO | ALLOWS_ONE;
153
154     /**
155     * Occurence indicator for "exactly one" (default occurrence indicator)
156     */

157
158     public static final int EXACTLY_ONE = ALLOWS_ONE;
159
160     /**
161     * Occurence indicator when an empty sequence is required
162     */

163
164     public static final int EMPTY = ALLOWS_ZERO;
165
166     /**
167      * REduce the cardinality value to an integer in the range 0-7
168      */

169
170     public static final int getCardinalityCode(int cardinality) {
171         return (cardinality & CARDINALITY_MASK) >> 13;
172     }
173
174     /**
175      * Expression property: this bit is set by getProperties() in the case of
176      * an expression whose item type is node, when the nodes in the result are
177      * guaranteed all to be in the same document as the context node. For
178      * expressions that return values other than nodes, the setting is undefined.
179      */

180
181     public static final int CONTEXT_DOCUMENT_NODESET = 1<<16;
182
183     /**
184      * Expression property: this bit is set by getProperties() in the case of
185      * an expression whose item type is node, when the nodes in the result are
186      * in document order.
187      */

188
189     public static final int ORDERED_NODESET = 1<<17;
190
191     /**
192      * Expression property: this bit is set by getProperties() in the case of
193      * an expression that delivers items in the reverse of the correct order, when unordered
194      * retrieval is requested.
195      */

196
197     public static final int REVERSE_DOCUMENT_ORDER = 1<<18;
198
199     /**
200      * Expression property: this bit is set by getProperties() in the case of
201      * an expression that delivers a set of nodes with the guarantee that no node in the
202      * set will be an ancestor of any other. This property is useful in deciding whether the
203      * results of a path expression are pre-sorted. The property is only used in the case where
204      * the NATURALLY_SORTED property is true, so there is no point in setting it in other cases.
205      */

206
207     public static final int PEER_NODESET = 1<<19;
208
209     /**
210      * Expression property: this bit is set by getProperties() in the case of
211      * an expression that delivers a set of nodes with the guarantee that every node in the
212      * result will be a descendant or self, or attribute or namespace, of the context node
213      */

214
215     public static final int SUBTREE_NODESET = 1<<20;
216
217     /**
218      * Expression property: this bit is set by getProperties() in the case of
219      * an expression that delivers a set of nodes with the guarantee that every node in the
220      * result will be an attribute or namespace of the context node
221      */

222
223     public static final int ATTRIBUTE_NS_NODESET = 1<<21;
224
225     /**
226      * Expression property: this bit is set in the case of an expression that will
227      * never return newly created nodes, nor a value that depends on the identity
228      * of newly created nodes (for example generate-id(new-node())). Expressions
229      * that do create new nodes cannot be moved out of loops as this could cause
230      * too few nodes to be created: for example if f() creates a new node, then
231      * count(for $i in 1 to 5 return f()) must be 5.
232      */

233
234     public static final int NON_CREATIVE = 1<<22;
235
236     /**
237      * Expression property: this bit is set in the case of an expression that delivers
238      * a set of nodes that are all in the same document (not necessarily the same
239      * document as the context node).
240      */

241
242     public static final int SINGLE_DOCUMENT_NODESET = 1<<23;
243
244     /**
245      * Mask for "special properties": that is, all properties other than cardinality
246      * and dependencies
247      */

248
249     public static final int SPECIAL_PROPERTY_MASK =
250             CONTEXT_DOCUMENT_NODESET |
251             ORDERED_NODESET |
252             REVERSE_DOCUMENT_ORDER |
253             PEER_NODESET |
254             SUBTREE_NODESET |
255             ATTRIBUTE_NS_NODESET |
256             SINGLE_DOCUMENT_NODESET |
257             NON_CREATIVE;
258
259     // This class is not instantiated
260
private StaticProperty() {}
261 }
262
263 //
264
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
265
// you may not use this file except in compliance with the License. You may obtain a copy of the
266
// License at http://www.mozilla.org/MPL/
267
//
268
// Software distributed under the License is distributed on an "AS IS" basis,
269
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
270
// See the License for the specific language governing rights and limitations under the License.
271
//
272
// The Original Code is: all this file.
273
//
274
// The Initial Developer of the Original Code is Michael H. Kay.
275
//
276
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
277
//
278
// Contributor(s): none.
279
//
280
Popular Tags