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