Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NamedValue |
|
| 1.4;1.4 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | package org.apache.commons.el; | |
18 | ||
19 | import javax.servlet.jsp.el.ELException; | |
20 | import javax.servlet.jsp.el.FunctionMapper; | |
21 | import javax.servlet.jsp.el.VariableResolver; | |
22 | ||
23 | /** | |
24 | * | |
25 | * <p>Represents a name that can be used as the first element of a | |
26 | * value. | |
27 | * | |
28 | * @author Nathan Abramson - Art Technology Group | |
29 | * @author Shawn Bayern | |
30 | * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: bayard $ | |
31 | **/ | |
32 | ||
33 | public class NamedValue | |
34 | extends Expression | |
35 | { | |
36 | //------------------------------------- | |
37 | // Constants | |
38 | //------------------------------------- | |
39 | ||
40 | //------------------------------------- | |
41 | // Properties | |
42 | //------------------------------------- | |
43 | // property name | |
44 | ||
45 | String mName; | |
46 | public String getName () | |
47 | 0 | { return mName; } |
48 | ||
49 | //------------------------------------- | |
50 | /** | |
51 | * | |
52 | * Constructor | |
53 | **/ | |
54 | public NamedValue (String pName) | |
55 | 0 | { |
56 | 0 | mName = pName; |
57 | 0 | } |
58 | ||
59 | //------------------------------------- | |
60 | // Expression methods | |
61 | //------------------------------------- | |
62 | /** | |
63 | * | |
64 | * Returns the expression in the expression language syntax | |
65 | **/ | |
66 | public String getExpressionString () | |
67 | { | |
68 | 0 | return StringLiteral.toIdentifierToken (mName); |
69 | } | |
70 | ||
71 | //------------------------------------- | |
72 | /** | |
73 | * | |
74 | * Evaluates by looking up the name in the VariableResolver | |
75 | **/ | |
76 | public Object evaluate (VariableResolver pResolver, FunctionMapper functions) | |
77 | throws ELException | |
78 | { | |
79 | 0 | if (pResolver == null) { |
80 | 0 | return null; |
81 | } | |
82 | else { | |
83 | 0 | return pResolver.resolveVariable (mName); |
84 | } | |
85 | } | |
86 | ||
87 | public Expression bindFunctions(FunctionMapper functions) throws ELException { | |
88 | 0 | return this; |
89 | } | |
90 | ||
91 | //------------------------------------- | |
92 | } |