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)
| 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. |
no test coverage detected