MCPcopy Create free account
hub / github.com/apache/tomcat / coerceToFloat

Method coerceToFloat

java/org/apache/jasper/compiler/JspUtil.java:565–577  ·  view source on GitHub ↗

Generates code to coerce a string to a Float object. @param s The string expression @param isNamedAttribute Whether the value comes from a named attribute @return the generated coercion code

(String s, boolean isNamedAttribute)

Source from the content-addressed store, hash-verified

563 * @return the generated coercion code
564 */
565 public static String coerceToFloat(String s, boolean isNamedAttribute) {
566 if (isNamedAttribute) {
567 return "(java.lang.Float) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s +
568 ", java.lang.Float.class)";
569 } else {
570 if (s == null || s.isEmpty()) {
571 return "java.lang.Float.valueOf(0)";
572 } else {
573 // Detect format error at translation time
574 return "java.lang.Float.valueOf(" + Generator.quote(s) + ")";
575 }
576 }
577 }
578
579 /**
580 * Generates code to coerce a string to a primitive int value.

Callers 1

convertStringMethod · 0.95

Calls 2

quoteMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected