KickJava   Java API By Example, From Geeks To Geeks.

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


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 import net.sf.saxon.value.IntegerValue;
9
10 /**
11 * Implement the XPath 1.0 function last()
12 */

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
46 //
47
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
48
// you may not use this file except in compliance with the License. You may obtain a copy of the
49
// License at http://www.mozilla.org/MPL/
50
//
51
// Software distributed under the License is distributed on an "AS IS" basis,
52
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
53
// See the License for the specific language governing rights and limitations under the License.
54
//
55
// The Original Code is: all this file.
56
//
57
// The Initial Developer of the Original Code is Michael H. Kay.
58
//
59
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
60
//
61
// Contributor(s): none.
62
//
63
Popular Tags