01: package net.sf.saxon.functions;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.expr.StaticContext;
05: import net.sf.saxon.expr.XPathContext;
06: import net.sf.saxon.om.Item;
07: import net.sf.saxon.om.SequenceIterator;
08: import net.sf.saxon.trans.XPathException;
09:
10: /**
11: * Abtract class representing a function call that is always rewritten at compile-time:
12: * it can never be executed
13: */
14:
15: public abstract class CompileTimeFunction extends SystemFunction {
16:
17: /**
18: * preEvaluate: this method suppresses compile-time evaluation by doing nothing.
19: * (this is because the default implementation of preEvaluate() calls evaluate() which
20: * is not available for these functions)
21: */
22:
23: public Expression preEvaluate(StaticContext env)
24: throws XPathException {
25: return this ;
26: }
27:
28: /**
29: * Evaluate as a single item
30: */
31:
32: public final Item evaluateItem(XPathContext c)
33: throws XPathException {
34: throw new IllegalStateException("Function " + getName(c)
35: + " should have been resolved at compile-time");
36: }
37:
38: /**
39: * Iterate over the results of the function
40: */
41:
42: public final SequenceIterator iterate(XPathContext c) {
43: throw new IllegalStateException("Function " + getName(c)
44: + " should have been resolved at compile-time");
45: }
46:
47: private String getName(XPathContext c) {
48: return getDisplayName(c.getNamePool());
49: }
50:
51: }
52:
53: //
54: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
55: // you may not use this file except in compliance with the License. You may obtain a copy of the
56: // License at http://www.mozilla.org/MPL/
57: //
58: // Software distributed under the License is distributed on an "AS IS" basis,
59: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
60: // See the License for the specific language governing rights and limitations under the License.
61: //
62: // The Original Code is: all this file.
63: //
64: // The Initial Developer of the Original Code is Michael H. Kay
65: //
66: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
67: //
68: // Contributor(s): none.
69: //
|