1 52 53 package freemarker.core; 54 55 import freemarker.template.*; 56 57 final class BooleanLiteral extends Expression { 58 59 private final boolean val; 60 61 public BooleanLiteral(boolean val) { 62 this.val = val; 63 } 64 65 static TemplateBooleanModel getTemplateModel(boolean b) { 66 return b? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; 67 } 68 69 boolean isTrue(Environment env) { 70 return val; 71 } 72 73 public String getCanonicalForm() { 74 return val ? "true" : "false"; 75 } 76 77 public String toString() { 78 return val ? "true" : "false"; 79 } 80 81 TemplateModel _getAsTemplateModel(Environment env) { 82 return val ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; 83 } 84 85 boolean isLiteral() { 86 return true; 87 } 88 89 Expression _deepClone(String name, Expression subst) { 90 return new BooleanLiteral(val); 91 } 92 } 93 | Popular Tags |