Lines 28-33
Link Here
|
28 |
import org.apache.taglibs.standard.lang.jstl.parser.Token; |
28 |
import org.apache.taglibs.standard.lang.jstl.parser.Token; |
29 |
import org.apache.taglibs.standard.lang.jstl.parser.TokenMgrError; |
29 |
import org.apache.taglibs.standard.lang.jstl.parser.TokenMgrError; |
30 |
|
30 |
|
|
|
31 |
import org.apache.taglibs.standard.util.*; |
32 |
|
31 |
/** |
33 |
/** |
32 |
* |
34 |
* |
33 |
* <p>This is the main class for evaluating expression Strings. An |
35 |
* <p>This is the main class for evaluating expression Strings. An |
Lines 91-102
Link Here
|
91 |
|
93 |
|
92 |
/** The mapping from expression String to its parsed form (String, |
94 |
/** The mapping from expression String to its parsed form (String, |
93 |
Expression, or ExpressionString) **/ |
95 |
Expression, or ExpressionString) **/ |
94 |
static Map sCachedExpressionStrings = |
96 |
static StandardTaglibCache sCachedExpressionStrings = |
95 |
Collections.synchronizedMap (new HashMap ()); |
97 |
StandardTaglibCacheFactory.createCache( |
|
|
98 |
Constants.ELEVALUATOR_EXPECTED_STRINGS_CACHE, |
99 |
ForeverStandardTaglibCache.class |
100 |
); |
96 |
|
101 |
|
97 |
/** The mapping from ExpectedType to Maps mapping literal String to |
102 |
/** The mapping from ExpectedType to Maps mapping literal String to |
98 |
parsed value **/ |
103 |
parsed value **/ |
99 |
static Map sCachedExpectedTypes = new HashMap (); |
104 |
static StandardTaglibCache sCachedExpectedTypes = |
|
|
105 |
StandardTaglibCacheFactory.createCache( |
106 |
Constants.ELEVALUATOR_EXPECTED_TYPES_CACHE, |
107 |
ForeverStandardTaglibCache.class |
108 |
); |
100 |
|
109 |
|
101 |
/** The static Logger **/ |
110 |
/** The static Logger **/ |
102 |
static Logger sLogger = new Logger (System.out); |
111 |
static Logger sLogger = new Logger (System.out); |
Lines 104-112
Link Here
|
104 |
/** The VariableResolver **/ |
113 |
/** The VariableResolver **/ |
105 |
VariableResolver mResolver; |
114 |
VariableResolver mResolver; |
106 |
|
115 |
|
107 |
/** Flag if the cache should be bypassed **/ |
|
|
108 |
boolean mBypassCache; |
109 |
|
110 |
//------------------------------------- |
116 |
//------------------------------------- |
111 |
/** |
117 |
/** |
112 |
* |
118 |
* |
Lines 124-148
Link Here
|
124 |
//------------------------------------- |
130 |
//------------------------------------- |
125 |
/** |
131 |
/** |
126 |
* |
132 |
* |
127 |
* Constructor |
|
|
128 |
* |
129 |
* @param pResolver the object that should be used to resolve |
130 |
* variable names encountered in expressions. If null, all variable |
131 |
* references will resolve to null. |
132 |
* |
133 |
* @param pBypassCache flag indicating if the cache should be |
134 |
* bypassed |
135 |
**/ |
136 |
public ELEvaluator (VariableResolver pResolver, |
137 |
boolean pBypassCache) |
138 |
{ |
139 |
mResolver = pResolver; |
140 |
mBypassCache = pBypassCache; |
141 |
} |
142 |
|
143 |
//------------------------------------- |
144 |
/** |
145 |
* |
146 |
* Evaluates the given expression String |
133 |
* Evaluates the given expression String |
147 |
* |
134 |
* |
148 |
* @param pExpressionString the expression String to be evaluated |
135 |
* @param pExpressionString the expression String to be evaluated |
Lines 248-257
Link Here
|
248 |
} |
235 |
} |
249 |
|
236 |
|
250 |
// See if it's in the cache |
237 |
// See if it's in the cache |
251 |
Object ret = |
238 |
Object ret = sCachedExpressionStrings.get (pExpressionString); |
252 |
mBypassCache ? |
|
|
253 |
null : |
254 |
sCachedExpressionStrings.get (pExpressionString); |
255 |
|
239 |
|
256 |
if (ret == null) { |
240 |
if (ret == null) { |
257 |
// Parse the expression |
241 |
// Parse the expression |
Lines 311-318
Link Here
|
311 |
|
295 |
|
312 |
// Find the cached value |
296 |
// Find the cached value |
313 |
Map valueByString = getOrCreateExpectedTypeMap (pExpectedType); |
297 |
Map valueByString = getOrCreateExpectedTypeMap (pExpectedType); |
314 |
if (!mBypassCache && |
298 |
if (valueByString.containsKey (pValue)) { |
315 |
valueByString.containsKey (pValue)) { |
|
|
316 |
return valueByString.get (pValue); |
299 |
return valueByString.get (pValue); |
317 |
} |
300 |
} |
318 |
else { |
301 |
else { |
Lines 331-344
Link Here
|
331 |
**/ |
314 |
**/ |
332 |
static Map getOrCreateExpectedTypeMap (Class pExpectedType) |
315 |
static Map getOrCreateExpectedTypeMap (Class pExpectedType) |
333 |
{ |
316 |
{ |
334 |
synchronized (sCachedExpectedTypes) { |
|
|
335 |
Map ret = (Map) sCachedExpectedTypes.get (pExpectedType); |
317 |
Map ret = (Map) sCachedExpectedTypes.get (pExpectedType); |
336 |
if (ret == null) { |
318 |
if (ret == null) { |
337 |
ret = Collections.synchronizedMap (new HashMap ()); |
319 |
ret = Collections.synchronizedMap (new HashMap ()); |
338 |
sCachedExpectedTypes.put (pExpectedType, ret); |
320 |
sCachedExpectedTypes.put (pExpectedType, ret); |
339 |
} |
321 |
} |
340 |
return ret; |
322 |
return ret; |
341 |
} |
|
|
342 |
} |
323 |
} |
343 |
|
324 |
|
344 |
//------------------------------------- |
325 |
//------------------------------------- |