~ubuntu-branches/debian/sid/tomcat6/sid

« back to all changes in this revision

Viewing changes to java/org/apache/el/MethodExpressionImpl.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-05-22 10:03:04 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20140522100304-mihmp51mlvi4mr0m
Tags: 6.0.41-1
* New upstream release.
  - Refreshed the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
42
 
43
43
/**
44
44
 * An <code>Expression</code> that refers to a method on an object.
45
 
 * 
 
45
 *
46
46
 * <p>
47
47
 * <code>The {@link ExpressionFactory#createMethodExpression} method
48
48
 * can be used to parse an expression string and return a concrete instance
49
49
 * of <code>MethodExpression</code> that encapsulates the parsed expression.
50
 
 * The {@link FunctionMapper} is used at parse time, not evaluation time, 
51
 
 * so one is not needed to evaluate an expression using this class.  
 
50
 * The {@link FunctionMapper} is used at parse time, not evaluation time,
 
51
 * so one is not needed to evaluate an expression using this class.
52
52
 * However, the {@link ELContext} is needed at evaluation time.</p>
53
53
 *
54
 
 * <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the 
55
 
 * expression each time they are called. The {@link ELResolver} in the 
56
 
 * <code>ELContext</code> is used to resolve the top-level variables and to 
57
 
 * determine the behavior of the <code>.</code> and <code>[]</code> 
58
 
 * operators. For any of the two methods, the {@link ELResolver#getValue} 
59
 
 * method is used to resolve all properties up to but excluding the last 
 
54
 * <p>The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the
 
55
 * expression each time they are called. The {@link ELResolver} in the
 
56
 * <code>ELContext</code> is used to resolve the top-level variables and to
 
57
 * determine the behavior of the <code>.</code> and <code>[]</code>
 
58
 * operators. For any of the two methods, the {@link ELResolver#getValue}
 
59
 * method is used to resolve all properties up to but excluding the last
60
60
 * one. This provides the <code>base</code> object on which the method
61
 
 * appears. If the <code>base</code> object is null, a 
62
 
 * <code>NullPointerException</code> must be thrown. At the last resolution, 
 
61
 * appears. If the <code>base</code> object is null, a
 
62
 * <code>NullPointerException</code> must be thrown. At the last resolution,
63
63
 * the final <code>property</code> is then coerced to a <code>String</code>,
64
 
 * which provides the name of the method to be found. A method matching the 
65
 
 * name and expected parameters provided at parse time is found and it is 
 
64
 * which provides the name of the method to be found. A method matching the
 
65
 * name and expected parameters provided at parse time is found and it is
66
66
 * either queried or invoked (depending on the method called on this
67
67
 * <code>MethodExpression</code>).</p>
68
68
 *
69
 
 * <p>See the notes about comparison, serialization and immutability in 
 
69
 * <p>See the notes about comparison, serialization and immutability in
70
70
 * the {@link Expression} javadocs.
71
71
 *
72
72
 * @see javax.el.ELResolver
73
73
 * @see javax.el.Expression
74
74
 * @see javax.el.ExpressionFactory
75
75
 * @see javax.el.MethodExpression
76
 
 * 
 
76
 *
77
77
 * @author Jacob Hookom [jacob@hookom.net]
78
 
 * @version $Id: MethodExpressionImpl.java 939519 2010-04-30 00:12:23Z kkolinko $
 
78
 *
79
79
 */
80
80
public final class MethodExpressionImpl extends MethodExpression implements
81
81
        Externalizable {
93
93
    private Class[] paramTypes;
94
94
 
95
95
    /**
96
 
     * 
 
96
     *
97
97
     */
98
98
    public MethodExpressionImpl() {
99
99
        super();
121
121
    /**
122
122
     * Determines whether the specified object is equal to this
123
123
     * <code>Expression</code>.
124
 
     * 
 
124
     *
125
125
     * <p>
126
126
     * The result is <code>true</code> if and only if the argument is not
127
127
     * <code>null</code>, is an <code>Expression</code> object that is the
129
129
     * <code>MethodExpression</code>), and has an identical parsed
130
130
     * representation.
131
131
     * </p>
132
 
     * 
 
132
     *
133
133
     * <p>
134
134
     * Note that two expressions can be equal if their expression Strings are
135
135
     * different. For example, <code>${fn1:foo()}</code> and
137
137
     * <code>FunctionMapper</code>s mapped <code>fn1:foo</code> and
138
138
     * <code>fn2:foo</code> to the same method.
139
139
     * </p>
140
 
     * 
 
140
     *
141
141
     * @param obj
142
142
     *            the <code>Object</code> to test for equality.
143
143
     * @return <code>true</code> if <code>obj</code> equals this
153
153
    /**
154
154
     * Returns the original String used to create this <code>Expression</code>,
155
155
     * unmodified.
156
 
     * 
 
156
     *
157
157
     * <p>
158
158
     * This is used for debugging purposes but also for the purposes of
159
159
     * comparison (e.g. to ensure the expression in a configuration file has not
160
160
     * changed).
161
161
     * </p>
162
 
     * 
 
162
     *
163
163
     * <p>
164
164
     * This method does not provide sufficient information to re-create an
165
165
     * expression. Two different expressions can have exactly the same
166
166
     * expression string but different function mappings. Serialization should
167
167
     * be used to save and restore the state of an <code>Expression</code>.
168
168
     * </p>
169
 
     * 
 
169
     *
170
170
     * @return The original expression String.
171
 
     * 
 
171
     *
172
172
     * @see javax.el.Expression#getExpressionString()
173
173
     */
174
174
    public String getExpressionString() {
178
178
    /**
179
179
     * Evaluates the expression relative to the provided context, and returns
180
180
     * information about the actual referenced method.
181
 
     * 
 
181
     *
182
182
     * @param context
183
183
     *            The context of this evaluation
184
184
     * @return an instance of <code>MethodInfo</code> containing information
206
206
        return n.getMethodInfo(ctx, this.paramTypes);
207
207
    }
208
208
 
209
 
    /**
210
 
     * @return
211
 
     * @throws ELException
212
 
     */
213
209
    private Node getNode() throws ELException {
214
210
        if (this.node == null) {
215
211
            this.node = ExpressionBuilder.createNode(this.expr);
219
215
 
220
216
    /**
221
217
     * Returns the hash code for this <code>Expression</code>.
222
 
     * 
 
218
     *
223
219
     * <p>
224
220
     * See the note in the {@link #equals} method on how two expressions can be
225
221
     * equal if their expression Strings are different. Recall that if two
228
224
     * objects must produce the same integer result. Implementations must take
229
225
     * special note and implement <code>hashCode</code> correctly.
230
226
     * </p>
231
 
     * 
 
227
     *
232
228
     * @return The hash code for this <code>Expression</code>.
233
229
     * @see #equals
234
230
     * @see java.util.Hashtable
242
238
     * Evaluates the expression relative to the provided context, invokes the
243
239
     * method that was found using the supplied parameters, and returns the
244
240
     * result of the method invocation.
245
 
     * 
 
241
     *
246
242
     * @param context
247
243
     *            The context of this evaluation.
248
244
     * @param params
278
274
 
279
275
    /*
280
276
     * (non-Javadoc)
281
 
     * 
 
277
     *
282
278
     * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
283
279
     */
284
280
    public void readExternal(ObjectInput in) throws IOException,
296
292
 
297
293
    /*
298
294
     * (non-Javadoc)
299
 
     * 
 
295
     *
300
296
     * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
301
297
     */
302
298
    public void writeExternal(ObjectOutput out) throws IOException {