1 52 53 package freemarker.core; 54 55 import freemarker.template.*; 56 57 62 final class NumberLiteral extends Expression implements TemplateNumberModel { 63 64 private final Number value; 65 66 public NumberLiteral(Number value) { 67 this.value = value; 68 } 69 70 TemplateModel _getAsTemplateModel(Environment env) { 71 return new SimpleNumber(value); 72 } 73 74 public String getStringValue(Environment env) { 75 return env.formatNumber(value); 76 } 77 78 public Number getAsNumber() { 79 return value; 80 } 81 82 String getName() { 83 return "the number: '" + value + "'"; 84 } 85 86 public String getCanonicalForm() { 87 return value.toString(); 88 } 89 90 boolean isLiteral() { 91 return true; 92 } 93 94 Expression _deepClone(String name, Expression subst) { 95 return new NumberLiteral(value); 96 } 97 98 } 99 | Popular Tags |