List of usage examples for org.apache.commons.jexl3 JexlInfo JexlInfo
public JexlInfo(String source, int l, int c)
From source file:org.everit.expression.jexl.JexlExpressionCompiler.java
@Override public CompiledExpression compile(final String expression, final ParserConfiguration parserConfiguration) { if (parserConfiguration == null) { throw new IllegalArgumentException("Parser configuration must be defined"); }/*from w w w . j a va 2 s . c om*/ JexlInfo jexlInfo = new JexlInfo(parserConfiguration.getName(), parserConfiguration.getStartRow(), parserConfiguration.getStartColumn()); String[] parameterNames = null; if (parserConfiguration.getVariableTypes() != null) { Set<String> parameterSet = parserConfiguration.getVariableTypes().keySet(); parameterNames = parameterSet.toArray(new String[parameterSet.size()]); } JexlEngine jexlEngine = new JexlBuilder().silent(false).debug(true) .loader(parserConfiguration.getClassLoader()).arithmetic(new CustomizedJexlArithmetic(true)) .create(); JexlScript script = jexlEngine.createScript(jexlInfo, expression, parameterNames); return new JexlCompiledExpression(script); }
From source file:org.sonatype.nexus.selector.JexlSelectorTest.java
@Test public void testPrettyExceptionMsgNoDetail() { // Setup// w w w. j a v a2 s .com String expected = "Invalid JEXL at line '2' column '4'."; JexlInfo info = new JexlInfo("", 2, 4); // Mocked because JexlException modifies msg internally after construction JexlException ex = mock(JexlException.class); doReturn(info).when(ex).getInfo(); doReturn("").when(ex).getMessage(); // Execute String returned = JexlSelector.prettyExceptionMsg(ex); // Verify assertNotNull("Returned string was not set.", returned); assertEquals(expected, returned); }