KickJava   Java API By Example, From Geeks To Geeks.

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


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
12 public class Position extends SystemFunction {
13
14     /**
15     * preEvaluate: this method suppresses compile-time evaluation by doing nothing
16     * (because the value of the expression depends on the runtime context)
17     */

18
19     public Expression preEvaluate(StaticContext env) {
20         return this;
21     }
22
23     /**
24     * Evaluate in a general context
25     */

26
27     public Item evaluateItem(XPathContext c) throws XPathException {
28         return new IntegerValue(c.getContextPosition());
29     }
30
31     /**
32     * Determine the intrinsic dependencies
33     */

34
35     public int getIntrinsicDependencies() {
36         return StaticProperty.DEPENDS_ON_POSITION;
37     }
38 }
39
40
41
42 //
43
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
44
// you may not use this file except in compliance with the License. You may obtain a copy of the
45
// License at http://www.mozilla.org/MPL/
46
//
47
// Software distributed under the License is distributed on an "AS IS" basis,
48
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
49
// See the License for the specific language governing rights and limitations under the License.
50
//
51
// The Original Code is: all this file.
52
//
53
// The Initial Developer of the Original Code is Michael H. Kay.
54
//
55
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
56
//
57
// Contributor(s): none.
58
//
59
Popular Tags