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.StaticProperty;
06: import net.sf.saxon.expr.XPathContext;
07: import net.sf.saxon.om.Item;
08: import net.sf.saxon.trans.XPathException;
09: import net.sf.saxon.value.IntegerValue;
10:
11: /**
12: * Implement the XPath 1.0 function last()
13: */
14:
15: public class Last extends SystemFunction {
16:
17: /**
18: * preEvaluate: this method suppresses compile-time evaluation by doing nothing
19: * (because the value of the expression depends on the runtime context)
20: */
21:
22: public Expression preEvaluate(StaticContext env) {
23: return this ;
24: }
25:
26: /**
27: * Evaluate in a general context
28: */
29:
30: public Item evaluateItem(XPathContext c) throws XPathException {
31: return new IntegerValue(c.getLast());
32: }
33:
34: /**
35: * Determine the dependencies
36: */
37:
38: public int getIntrinsicDependencies() {
39: return StaticProperty.DEPENDS_ON_LAST;
40: }
41:
42: }
43:
44: //
45: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
46: // you may not use this file except in compliance with the License. You may obtain a copy of the
47: // License at http://www.mozilla.org/MPL/
48: //
49: // Software distributed under the License is distributed on an "AS IS" basis,
50: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
51: // See the License for the specific language governing rights and limitations under the License.
52: //
53: // The Original Code is: all this file.
54: //
55: // The Initial Developer of the Original Code is Michael H. Kay.
56: //
57: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
58: //
59: // Contributor(s): none.
60: //
|