MCPcopy Index your code
hub / github.com/apache/tomcat / coerceToBoolean

Method coerceToBoolean

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

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

convertStringMethod · 0.95

Calls 2

quoteMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected