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

Method coerceToShort

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

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

convertStringMethod · 0.95

Calls 2

quoteMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected