KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > instruct > UserFunctionParameter


1 package net.sf.saxon.instruct;
2
3 import net.sf.saxon.expr.Binding;
4 import net.sf.saxon.expr.XPathContext;
5 import net.sf.saxon.om.ValueRepresentation;
6 import net.sf.saxon.trans.XPathException;
7 import net.sf.saxon.value.SequenceType;
8
9 import java.io.Serializable JavaDoc;
10
11 /**
12  * Run-time object representing a formal argument to a user-defined function
13  */

14 public class UserFunctionParameter implements Binding, Serializable JavaDoc {
15
16     private SequenceType requiredType;
17     private int slotNumber;
18     private int referenceCount = 999;
19         // The initial value is deliberately set to indicate "many" so that it will be assumed a parameter
20
// is referenced repeatedly until proved otherwise
21

22     /**
23      * Indicate whether the binding is local or global. A global binding is one that has a fixed
24      * value for the life of a query or transformation; any other binding is local.
25      */

26
27     public final boolean isGlobal() {
28         return false;
29     }
30
31     /**
32     * Test whether it is permitted to assign to the variable using the saxon:assign
33     * extension element. This will only be for an XSLT global variable where the extra
34     * attribute saxon:assignable="yes" is present.
35     */

36
37     public final boolean isAssignable() {
38         return false;
39     }
40
41     /**
42      * If this is a local variable held on the local stack frame, return the corresponding slot number.
43      * In other cases, return -1.
44      */

45
46     public int getLocalSlotNumber() {
47         return slotNumber;
48     }
49
50     public void setRequiredType(SequenceType type) {
51         requiredType = type;
52     }
53
54     public SequenceType getRequiredType() {
55         return requiredType;
56     }
57
58     public void setReferenceCount(int count) {
59         referenceCount = count;
60     }
61
62     public int getReferenceCount() {
63         return referenceCount;
64     }
65
66     public void setSlotNumber(int slot) {
67         slotNumber = slot;
68     }
69
70     public ValueRepresentation evaluateVariable(XPathContext context) throws XPathException {
71         return context.evaluateLocalVariable(slotNumber);
72     }
73
74 }
75
76 //
77
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
78
// you may not use this file except in compliance with the License. You may obtain a copy of the
79
// License at http://www.mozilla.org/MPL/
80
//
81
// Software distributed under the License is distributed on an "AS IS" basis,
82
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
83
// See the License for the specific language governing rights and limitations under the License.
84
//
85
// The Original Code is: all this file.
86
//
87
// The Initial Developer of the Original Code is Michael H. Kay
88
//
89
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
90
//
91
// Contributor(s): none
92
//
Popular Tags