MCPcopy Create free account
hub / github.com/apache/freemarker / isTrue

Method isTrue

src/main/java/freemarker/core/Expression.java:137–151  ·  view source on GitHub ↗
(Environment env)

Source from the content-addressed store, hash-verified

135 abstract Expression _deepClone(String name, Expression subst);
136
137 boolean isTrue(Environment env) throws TemplateException {
138 TemplateModel referent = getAsTemplateModel(env);
139 if (referent instanceof TemplateBooleanModel) {
140 return ((TemplateBooleanModel) referent).getAsBoolean();
141 }
142 if (env.isClassicCompatible()) {
143 return referent != null && !isEmpty(referent);
144 }
145 assertNonNull(referent, this, env);
146 String msg = "Error " + getStartLocation()
147 + "\nExpecting a boolean (true/false) expression here"
148 + "\nExpression " + this + " does not evaluate to true/false "
149 + "\nit is an instance of " + referent.getClass().getName();
150 throw new NonBooleanException(msg, env);
151 }
152
153
154 static boolean isEmpty(TemplateModel model) throws TemplateModelException

Callers 1

acceptMethod · 0.95

Calls 8

getAsTemplateModelMethod · 0.95
isEmptyMethod · 0.95
isClassicCompatibleMethod · 0.80
assertNonNullMethod · 0.80
getStartLocationMethod · 0.80
getClassMethod · 0.80
getAsBooleanMethod · 0.65
getNameMethod · 0.45

Tested by

no test coverage detected