Generates code to coerce a string to a Boolean 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)
| 401 | * @return the generated coercion code |
| 402 | */ |
| 403 | public static String coerceToBoolean(String s, boolean isNamedAttribute) { |
| 404 | if (isNamedAttribute) { |
| 405 | return "(java.lang.Boolean) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + |
| 406 | ", java.lang.Boolean.class)"; |
| 407 | } else { |
| 408 | if (s == null || s.isEmpty()) { |
| 409 | return "java.lang.Boolean.FALSE"; |
| 410 | } else { |
| 411 | // Detect format error at translation time |
| 412 | return "java.lang.Boolean.valueOf(" + Generator.quote(s) + ")"; |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | /** |
| 418 | * Generates code to coerce a string to a primitive byte value. |
no test coverage detected