use of org.beetl.core.ContextFormat in project beetl2.0 by javamonkey.
the class FormatExpression method evaluateValue.
public Object evaluateValue(Object o, Context ctx) {
Format format = null;
if (name != null) {
format = ctx.gt.getFormat(name);
} else {
if (o == null)
return null;
format = ctx.gt.getDefaultFormat(o.getClass());
}
if (format == null) {
BeetlException ex = new BeetlException(BeetlException.FORMAT_NOT_FOUND);
ex.pushToken(token);
throw ex;
}
try {
if (format instanceof ContextFormat) {
return ((ContextFormat) format).format(o, pattern, ctx);
} else {
return format.format(o, pattern);
}
} catch (Exception e) {
BeetlException ex = new BeetlException(BeetlException.NATIVE_CALL_EXCEPTION, "调用格式化函数抛出异常", e);
ex.pushToken(token);
throw ex;
}
}
Aggregations