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

Method coerceToInteger

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

Generates code to coerce a string to an Integer 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

603 * @return the generated coercion code
604 */
605 public static String coerceToInteger(String s, boolean isNamedAttribute) {
606 if (isNamedAttribute) {
607 return "(java.lang.Integer) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s +
608 ", java.lang.Integer.class)";
609 } else {
610 if (s == null || s.isEmpty()) {
611 return "java.lang.Integer.valueOf(0)";
612 } else {
613 // Detect format error at translation time
614 return "java.lang.Integer.valueOf(" + Generator.quote(s) + ")";
615 }
616 }
617 }
618
619 /**
620 * Generates code to coerce a string to a primitive short value.

Callers 1

convertStringMethod · 0.95

Calls 2

quoteMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected