KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > lang > jpath > expression > IntrospectionOperator


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.lang.jpath.expression;
18
19 import javax.servlet.jsp.PageContext JavaDoc;
20
21 import org.apache.taglibs.standard.lang.jpath.adapter.IterationContext;
22
23 /**
24  * The IntrospectionOperator class
25  *
26  *
27  * @author <a HREF='mailto:scott.hasse@isthmusgroup.com'>Scott Hasse</a>
28  * @version
29  */

30 public class IntrospectionOperator extends SimpleNode
31         implements Introspectable {
32
33     /**
34      * Used to create an instance of the IntrospectionOperator class
35      *
36      *
37      * @param id
38      *
39      */

40     public IntrospectionOperator(int id) {
41         super(id);
42     }
43
44     /**
45      * Used to create an instance of the IntrospectionOperator class
46      *
47      *
48      * @param p
49      * @param id
50      *
51      */

52     public IntrospectionOperator(Parser p, int id) {
53         super(p, id);
54     }
55
56     /**
57      * Provides a method to print a normalized version of the original
58      * expression. The normalized version has standardized spacing and
59      * parenthesis, and can be used to compare expressions formatted
60      * in different ways to see if they are actually the same expression.
61      *
62      *
63      * @return The normalized version of the original expression
64      *
65      */

66     public String JavaDoc toNormalizedString() {
67
68         String JavaDoc normalized = "";
69
70         normalized = jjtGetChild(0).toNormalizedString()
71                 + getTokenImage(ParserConstants.INTROSPECT)
72                 + jjtGetChild(1).toNormalizedString();
73
74         return normalized;
75     }
76
77     /**
78      * This method evaluates this node of the expression and all child nodes.
79      * It returns the result of the
80      * evaluation as an <tt>Object</tt>. If any problems are encountered
81      * during the evaluation, an <tt>EvaluationException</tt> is thrown.
82      *
83      *
84      * @param pageContext the current JSP PageContext
85      *
86      * @param icontext the Iteration Context of the expression. If there is
87      * no interation context, this should be null.
88      *
89      * @return the result of the expression evaluation as an object
90      *
91      * @throws EvaluationException if a problem is encountered during the
92      * evaluation
93      */

94     public Object JavaDoc evaluate(PageContext JavaDoc pageContext, IterationContext icontext)
95             throws EvaluationException {
96
97         Object JavaDoc leftSide = jjtGetChild(0).evaluate(pageContext, icontext);
98         Object JavaDoc result =
99             ((Introspectable) jjtGetChild(1)).evaluate(pageContext, icontext,
100                 leftSide);
101
102         return result;
103     }
104
105     /**
106      * The evaluate method
107      *
108      *
109      * @param pageContext
110      * @param icontext
111      * @param scope
112      *
113      * @return
114      *
115      * @throws EvaluationException
116      *
117      */

118     public Object JavaDoc evaluate(
119             PageContext JavaDoc pageContext, IterationContext icontext, int scope)
120                 throws EvaluationException {
121
122         Object JavaDoc leftSide = ((Identifier) jjtGetChild(0)).evaluate(pageContext,
123                               icontext, scope);
124         Object JavaDoc result =
125             ((Introspectable) jjtGetChild(1)).evaluate(pageContext, icontext,
126                 leftSide);
127
128         return result;
129     }
130
131     /**
132      * The evaluate method
133      *
134      *
135      * @param pageContext
136      * @param icontext
137      * @param parent
138      *
139      * @return
140      *
141      * @throws EvaluationException
142      *
143      */

144     public Object JavaDoc evaluate(
145             PageContext JavaDoc pageContext, IterationContext icontext, Object JavaDoc parent)
146                 throws EvaluationException {
147
148         Object JavaDoc leftSide =
149             ((Introspectable) jjtGetChild(0)).evaluate(pageContext, icontext,
150                 parent);
151         Object JavaDoc result =
152             ((Introspectable) jjtGetChild(1)).evaluate(pageContext, icontext,
153                 leftSide);
154
155         return result;
156     }
157 }
158
Popular Tags