01: package net.sf.saxon.instruct;
02:
03: import net.sf.saxon.expr.Binding;
04: import net.sf.saxon.expr.XPathContext;
05: import net.sf.saxon.om.ValueRepresentation;
06: import net.sf.saxon.trans.XPathException;
07: import net.sf.saxon.value.SequenceType;
08:
09: import java.io.Serializable;
10:
11: /**
12: * Run-time object representing a formal argument to a user-defined function
13: */
14: public class UserFunctionParameter implements Binding, Serializable {
15:
16: private SequenceType requiredType;
17: private int slotNumber;
18: private int referenceCount = 999;
19:
20: // The initial value is deliberately set to indicate "many" so that it will be assumed a parameter
21: // is referenced repeatedly until proved otherwise
22:
23: /**
24: * Indicate whether the binding is local or global. A global binding is one that has a fixed
25: * value for the life of a query or transformation; any other binding is local.
26: */
27:
28: public final boolean isGlobal() {
29: return false;
30: }
31:
32: /**
33: * Test whether it is permitted to assign to the variable using the saxon:assign
34: * extension element. This will only be for an XSLT global variable where the extra
35: * attribute saxon:assignable="yes" is present.
36: */
37:
38: public final boolean isAssignable() {
39: return false;
40: }
41:
42: /**
43: * If this is a local variable held on the local stack frame, return the corresponding slot number.
44: * In other cases, return -1.
45: */
46:
47: public int getLocalSlotNumber() {
48: return slotNumber;
49: }
50:
51: public void setRequiredType(SequenceType type) {
52: requiredType = type;
53: }
54:
55: public SequenceType getRequiredType() {
56: return requiredType;
57: }
58:
59: public void setReferenceCount(int count) {
60: referenceCount = count;
61: }
62:
63: public int getReferenceCount() {
64: return referenceCount;
65: }
66:
67: public void setSlotNumber(int slot) {
68: slotNumber = slot;
69: }
70:
71: public ValueRepresentation evaluateVariable(XPathContext context)
72: throws XPathException {
73: return context.evaluateLocalVariable(slotNumber);
74: }
75:
76: }
77:
78: //
79: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
80: // you may not use this file except in compliance with the License. You may obtain a copy of the
81: // License at http://www.mozilla.org/MPL/
82: //
83: // Software distributed under the License is distributed on an "AS IS" basis,
84: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
85: // See the License for the specific language governing rights and limitations under the License.
86: //
87: // The Original Code is: all this file.
88: //
89: // The Initial Developer of the Original Code is Michael H. Kay
90: //
91: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
92: //
93: // Contributor(s): none
94: //
|