我正在尝试在表达式String中使用BigDecimal Literal
我正在使用JEXL 2.1.1
我正在使用http://commons.apache.org/jexl/reference/syntax.html#Literals
JexlEngine expressionFactory = new JexlEngine();
JexlContext context = new MapContext();
context.set ( "a", new BigDecimal( "0.0002" ));
Expression expression = expressionFactory.createExpression(" a > 42.0h " );
boolean result=(Boolean)expression.evaluate( context );
我正处于异常
之下org.apache.commons.jexl2.JexlException$Parsing: h@1:24 parsing error near '... , missing ...'
at org.apache.commons.jexl2.parser.JexlParser.jjtreeCloseNodeScope(JexlParser.java:126)
at org.apache.commons.jexl2.parser.Parser.ExpressionStatement(Parser.java:274)
at org.apache.commons.jexl2.parser.Parser.Statement(Parser.java:140)
at org.apache.commons.jexl2.parser.Parser.JexlScript(Parser.java:72)
at org.apache.commons.jexl2.parser.Parser.parse(Parser.java:24)
at org.apache.commons.jexl2.JexlEngine.parse(JexlEngine.java:1248)
at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:435)
at org.apache.commons.jexl2.JexlEngine.createExpression(JexlEngine.java:419)
答案 0 :(得分:1)
它看起来像文档错误。 正确的大十进制后缀是'B'(而不是'H') 正确的大整数后缀是'H'(而不是'B') 通过查看ASTNumberLiteral.java
可以清楚地验证这一点