Generates code to coerce a string to a Byte 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)
| 441 | * @return the generated coercion code |
| 442 | */ |
| 443 | public static String coerceToByte(String s, boolean isNamedAttribute) { |
| 444 | if (isNamedAttribute) { |
| 445 | return "(java.lang.Byte) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + |
| 446 | ", java.lang.Byte.class)"; |
| 447 | } else { |
| 448 | if (s == null || s.isEmpty()) { |
| 449 | return "java.lang.Byte.valueOf((byte) 0)"; |
| 450 | } else { |
| 451 | // Detect format error at translation time |
| 452 | return "java.lang.Byte.valueOf(" + Generator.quote(s) + ")"; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Generates code to coerce a string to a primitive char value. |
no test coverage detected