Generates code to coerce a string to a Short 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)
| 643 | * @return the generated coercion code |
| 644 | */ |
| 645 | public static String coerceToShort(String s, boolean isNamedAttribute) { |
| 646 | if (isNamedAttribute) { |
| 647 | return "(java.lang.Short) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + |
| 648 | ", java.lang.Short.class)"; |
| 649 | } else { |
| 650 | if (s == null || s.isEmpty()) { |
| 651 | return "java.lang.Short.valueOf((short) 0)"; |
| 652 | } else { |
| 653 | // Detect format error at translation time |
| 654 | return "java.lang.Short.valueOf(" + Generator.quote(s) + ")"; |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * Generates code to coerce a string to a primitive long value. |
no test coverage detected