KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sf.saxon.instruct;
2
3 import net.sf.saxon.expr.ComputedExpression;
4 import net.sf.saxon.expr.Container;
5 import net.sf.saxon.expr.Expression;
6 import net.sf.saxon.expr.ExpressionTool;
7 import net.sf.saxon.event.LocationProvider;
8
9 import java.io.Serializable JavaDoc;
10
11 /**
12  * This object represents the compiled form of a user-written function, template, attribute-set, etc
13  * (the source can be either an XSLT stylesheet function or an XQuery function).
14  *
15  * <p>It is assumed that type-checking, of both the arguments and the results,
16  * has been handled at compile time. That is, the expression supplied as the body
17  * of the function must be wrapped in code to check or convert the result to the
18  * required type, and calls on the function must be wrapped at compile time to check or
19  * convert the supplied arguments.
20  */

21
22 public class Procedure implements Serializable JavaDoc, Container, LocationProvider {
23
24     private Expression body;
25     private Executable executable;
26     private String JavaDoc systemId;
27     private int lineNumber;
28     private SlotManager stackFrameMap;
29
30     public Procedure() {};
31
32     public void setBody(Expression body) {
33         this.body = body;
34         ExpressionTool.makeParentReferences(body);
35         if (body instanceof ComputedExpression) {
36             ((ComputedExpression)body).setParentExpression(this);
37         }
38     }
39
40     public final Expression getBody() {
41         return body;
42     }
43
44     public void setStackFrameMap(SlotManager map) {
45         stackFrameMap = map;
46     }
47
48     public SlotManager getStackFrameMap() {
49         return stackFrameMap;
50     }
51
52     public final Executable getExecutable() {
53         return executable;
54     }
55
56     public void setExecutable(Executable executable) {
57         this.executable = executable;
58     }
59
60     /**
61      * Get the LocationProvider allowing location identifiers to be resolved.
62      */

63
64     public LocationProvider getLocationProvider() {
65         return this;
66     }
67
68     public void setLineNumber(int lineNumber) {
69         this.lineNumber = lineNumber;
70     }
71
72     public void setSystemId(String JavaDoc systemId) {
73         this.systemId = systemId;
74     }
75
76     public int getLineNumber() {
77         return lineNumber;
78     }
79
80     public String JavaDoc getSystemId() {
81         return systemId;
82     }
83
84     public int getColumnNumber() {
85         return -1;
86     }
87
88     public String JavaDoc getPublicId() {
89         return null;
90     }
91
92     public String JavaDoc getSystemId(int locationId) {
93         return systemId;
94     }
95
96     public int getLineNumber(int locationId) {
97         return lineNumber;
98     }
99
100 }
101
102
103 //
104
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
105
// you may not use this file except in compliance with the License. You may obtain a copy of the
106
// License at http://www.mozilla.org/MPL/
107
//
108
// Software distributed under the License is distributed on an "AS IS" basis,
109
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
110
// See the License for the specific language governing rights and limitations under the License.
111
//
112
// The Original Code is: all this file.
113
//
114
// The Initial Developer of the Original Code is Michael H. Kay
115
//
116
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
117
//
118
// Contributor(s): none
119
//
120
Popular Tags