Produces a String representing a call to the EL interpreter. @param isTagFile true if the file is a tag file rather than a JSP @param expression a String containing zero or more "${}" expressions @param expectedType the expected type of the interpreted result @param fnmapvar V
(boolean isTagFile, String expression, Class<?> expectedType, String fnmapvar)
| 310 | * @return a String representing a call to the EL interpreter. |
| 311 | */ |
| 312 | public static String interpreterCall(boolean isTagFile, String expression, Class<?> expectedType, String fnmapvar) { |
| 313 | /* |
| 314 | * Determine which context object to use. |
| 315 | */ |
| 316 | String jspCtxt; |
| 317 | if (isTagFile) { |
| 318 | jspCtxt = "this.getJspContext()"; |
| 319 | } else { |
| 320 | jspCtxt = "_jspx_page_context"; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Determine whether to use the expected type's textual name or, if it's a primitive, the name of its |
| 325 | * correspondent boxed type. |
| 326 | */ |
| 327 | String returnType = expectedType.getCanonicalName(); |
| 328 | String targetType = returnType; |
| 329 | String primitiveConverterMethod = null; |
| 330 | if (expectedType.isPrimitive()) { |
| 331 | if (expectedType.equals(Boolean.TYPE)) { |
| 332 | returnType = Boolean.class.getName(); |
| 333 | primitiveConverterMethod = "booleanValue"; |
| 334 | } else if (expectedType.equals(Byte.TYPE)) { |
| 335 | returnType = Byte.class.getName(); |
| 336 | primitiveConverterMethod = "byteValue"; |
| 337 | } else if (expectedType.equals(Character.TYPE)) { |
| 338 | returnType = Character.class.getName(); |
| 339 | primitiveConverterMethod = "charValue"; |
| 340 | } else if (expectedType.equals(Short.TYPE)) { |
| 341 | returnType = Short.class.getName(); |
| 342 | primitiveConverterMethod = "shortValue"; |
| 343 | } else if (expectedType.equals(Integer.TYPE)) { |
| 344 | returnType = Integer.class.getName(); |
| 345 | primitiveConverterMethod = "intValue"; |
| 346 | } else if (expectedType.equals(Long.TYPE)) { |
| 347 | returnType = Long.class.getName(); |
| 348 | primitiveConverterMethod = "longValue"; |
| 349 | } else if (expectedType.equals(Float.TYPE)) { |
| 350 | returnType = Float.class.getName(); |
| 351 | primitiveConverterMethod = "floatValue"; |
| 352 | } else if (expectedType.equals(Double.TYPE)) { |
| 353 | returnType = Double.class.getName(); |
| 354 | primitiveConverterMethod = "doubleValue"; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | /* |
| 359 | * Build up the base call to the interpreter. |
| 360 | */ |
| 361 | targetType = toJavaSourceType(targetType); |
| 362 | StringBuilder call = new StringBuilder("(" + returnType + ") " + |
| 363 | "org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate" + "(" + Generator.quote(expression) + |
| 364 | ", " + targetType + ".class, " + "(jakarta.servlet.jsp.PageContext)" + jspCtxt + ", " + fnmapvar + ")"); |
| 365 | |
| 366 | /* |
| 367 | * Add the primitive converter method if we need to. |
| 368 | */ |
| 369 | if (primitiveConverterMethod != null) { |
no test coverage detected