1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.el;
18
19 import java.util.List;
20 import java.util.ArrayList;
21
22 import javax.servlet.jsp.el.ELException;
23 import javax.servlet.jsp.el.FunctionMapper;
24 import javax.servlet.jsp.el.VariableResolver;
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class ComplexValue
39 extends Expression
40 {
41
42
43
44
45
46 Expression mPrefix;
47 public Expression getPrefix ()
48 { return mPrefix; }
49 public void setPrefix (Expression pPrefix)
50 { mPrefix = pPrefix; }
51
52
53
54
55 List mSuffixes;
56 public List getSuffixes ()
57 { return mSuffixes; }
58 public void setSuffixes (List pSuffixes)
59 { mSuffixes = pSuffixes; }
60
61
62
63
64
65
66 public ComplexValue (Expression pPrefix,
67 List pSuffixes)
68 {
69 mPrefix = pPrefix;
70 mSuffixes = pSuffixes;
71 }
72
73
74
75
76
77
78
79
80 public String getExpressionString ()
81 {
82 StringBuffer buf = new StringBuffer ();
83 buf.append (mPrefix.getExpressionString ());
84
85 for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) {
86 ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i);
87 buf.append (suffix.getExpressionString ());
88 }
89
90 return buf.toString ();
91 }
92
93
94
95
96
97
98 public Object evaluate (VariableResolver pResolver,
99 FunctionMapper functions)
100 throws ELException
101 {
102 Object ret = mPrefix.evaluate (pResolver, functions);
103
104
105 for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) {
106 ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i);
107 ret = suffix.evaluate (ret, pResolver, functions);
108 }
109
110 return ret;
111 }
112
113 public Expression bindFunctions(final FunctionMapper functions) throws ELException {
114 final List suffixes = new ArrayList(mSuffixes.size());
115 for (int i = 0; mSuffixes != null && i < mSuffixes.size (); i++) {
116 ValueSuffix suffix = (ValueSuffix) mSuffixes.get (i);
117 suffixes.add(suffix.bindFunctions(functions));
118 }
119 return new ComplexValue(mPrefix.bindFunctions(functions), suffixes);
120 }
121
122
123 }