KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sf.saxon.instruct;
2 import net.sf.saxon.expr.*;
3 import net.sf.saxon.om.ValueRepresentation;
4 import net.sf.saxon.style.StandardNames;
5 import net.sf.saxon.trans.XPathException;
6 import net.sf.saxon.type.ItemType;
7
8 import java.util.List JavaDoc;
9
10 /**
11 * An instruction derived from a xsl:with-param element in the stylesheet. <br>
12 */

13
14 public class WithParam extends GeneralVariable {
15
16     public WithParam() {}
17
18     public int getInstructionNameCode() {
19         return StandardNames.XSL_WITH_PARAM;
20     }
21
22     public TailCall processLeavingTail(XPathContext context) throws XPathException {
23         // not used
24
return null;
25     }
26
27     public static void simplify(WithParam[] params, StaticContext env) throws XPathException {
28          for (int i=0; i<params.length; i++) {
29             Expression select = params[i].getSelectExpression();
30             if (select != null) {
31                 params[i].setSelectExpression(select.simplify(env));
32             }
33         }
34     }
35
36 // public static void analyze(WithParam[] params, StaticContext env, ItemType contextItemType) throws XPathException {
37
// for (int i=0; i<params.length; i++) {
38
// Expression select = params[i].getSelectExpression();
39
// if (select != null) {
40
// params[i].setSelectExpression(select.analyze(env, contextItemType));
41
// }
42
// }
43
// }
44

45     public static void typeCheck(WithParam[] params, StaticContext env, ItemType contextItemType) throws XPathException {
46          for (int i=0; i<params.length; i++) {
47             Expression select = params[i].getSelectExpression();
48             if (select != null) {
49                 params[i].setSelectExpression(select.typeCheck(env, contextItemType));
50             }
51         }
52     }
53
54     public static void optimize(Optimizer opt, WithParam[] params, StaticContext env, ItemType contextItemType) throws XPathException {
55          for (int i=0; i<params.length; i++) {
56             Expression select = params[i].getSelectExpression();
57             if (select != null) {
58                 params[i].setSelectExpression(select.optimize(opt, env, contextItemType));
59             }
60         }
61     }
62
63    /**
64      * Promote the expressions in a set of with-param elements. This is a convenience
65      * method for use by subclasses.
66      */

67
68     public static void promoteParams(WithParam[] params, PromotionOffer offer) throws XPathException {
69         for (int i=0; i<params.length; i++) {
70             Expression select = params[i].getSelectExpression();
71             if (select != null) {
72                 params[i].setSelectExpression(select.promote(offer));
73             }
74         }
75     }
76
77     /**
78      * Get the XPath expressions used in an array of WithParam parameters (add them to the supplied list)
79      */

80
81     public static void getXPathExpressions(WithParam[] params, List JavaDoc list) {
82         for (int i=0; i<params.length; i++) {
83             Expression exp = params[i].getSelectExpression();
84             if (exp != null) {
85                 list.add(exp);
86             }
87         }
88     }
89
90     /**
91      * Evaluate the variable (method exists only to satisfy the interface)
92      */

93
94     public ValueRepresentation evaluateVariable(XPathContext context) throws XPathException {
95         throw new UnsupportedOperationException JavaDoc();
96     }
97 }
98
99 //
100
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
101
// you may not use this file except in compliance with the License. You may obtain a copy of the
102
// License at http://www.mozilla.org/MPL/
103
//
104
// Software distributed under the License is distributed on an "AS IS" basis,
105
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
106
// See the License for the specific language governing rights and limitations under the License.
107
//
108
// The Original Code is: all this file.
109
//
110
// The Initial Developer of the Original Code is Michael H. Kay.
111
//
112
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
113
//
114
// Contributor(s): none.
115
//
116
Popular Tags