KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > functions > Current


1 package net.sf.saxon.functions;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.expr.StaticContext;
4 import net.sf.saxon.expr.StaticProperty;
5 import net.sf.saxon.expr.XPathContext;
6 import net.sf.saxon.om.Item;
7 import net.sf.saxon.trans.XPathException;
8
9 /**
10  * Implement the XSLT current() function
11  */

12
13 public class Current extends SystemFunction implements XSLTFunction {
14
15     /**
16     * Get the static properties of this expression (other than its type). The result is
17     * bit-signficant. These properties are used for optimizations. In general, if
18     * property bit is set, it is true, but if it is unset, the value is unknown.
19     */

20
21     public int computeSpecialProperties() {
22         return StaticProperty.CONTEXT_DOCUMENT_NODESET |
23                 StaticProperty.SINGLE_DOCUMENT_NODESET |
24                 StaticProperty.ORDERED_NODESET |
25                 StaticProperty.NON_CREATIVE;
26     }
27
28     /**
29     * preEvaluate: this method suppresses compile-time evaluation by doing nothing
30     * (because the value of the expression depends on the runtime context)
31     */

32
33     public Expression preEvaluate(StaticContext env) {
34         return this;
35     }
36
37     /**
38     * Evaluate in a general context
39     */

40
41     public Item evaluateItem(XPathContext c) throws XPathException {
42         throw new AssertionError JavaDoc("current() function should have been rewritten at compile time");
43         // We rely on the expression being statically rewritten so that current() is promoted to the top level.
44
//return c.getContextItem();
45
//return c.getCurrentStylesheetItem();
46
}
47
48     /**
49     * Determine the dependencies
50     */

51
52     public int getIntrinsicDependencies() {
53        return StaticProperty.DEPENDS_ON_CURRENT_ITEM;
54     }
55
56 }
57
58
59
60
61 //
62
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
63
// you may not use this file except in compliance with the License. You may obtain a copy of the
64
// License at http://www.mozilla.org/MPL/
65
//
66
// Software distributed under the License is distributed on an "AS IS" basis,
67
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
68
// See the License for the specific language governing rights and limitations under the License.
69
//
70
// The Original Code is: all this file.
71
//
72
// The Initial Developer of the Original Code is Michael H. Kay.
73
//
74
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
75
//
76
// Contributor(s): none.
77
//
78
Popular Tags