use of org.apache.commons.jexl3.JexlException in project dbeaver by serge-rider.
the class AbstractDescriptor method parseExpression.
public static Expression parseExpression(String exprString) throws DBException {
synchronized (AbstractDescriptor.class) {
if (jexlEngine == null) {
jexlEngine = new JexlEngine(null, null, null, null);
jexlEngine.setCache(100);
}
}
try {
return jexlEngine.createExpression(exprString);
} catch (JexlException e) {
throw new DBException("Bad expression", e);
}
}
use of org.apache.commons.jexl3.JexlException in project dbeaver by dbeaver.
the class AbstractDescriptor method parseExpression.
public static Expression parseExpression(String exprString) throws DBException {
synchronized (AbstractDescriptor.class) {
if (jexlEngine == null) {
jexlEngine = new JexlEngine(null, null, null, null);
jexlEngine.setCache(100);
}
}
try {
return jexlEngine.createExpression(exprString);
} catch (JexlException e) {
throw new DBException("Bad expression", e);
}
}
use of org.apache.commons.jexl3.JexlException in project opennms by OpenNMS.
the class JexlIndexStorageStrategy method getResourceNameFromIndex.
/**
* {@inheritDoc}
*/
@Override
public String getResourceNameFromIndex(CollectionResource resource) {
String resourceName = null;
try {
UnifiedJEXL.Expression expr = EL.parse(m_parameters.get(PARAM_INDEX_FORMAT));
JexlContext context = new MapContext();
m_parameters.entrySet().forEach((entry) -> {
context.set(entry.getKey(), entry.getValue());
});
updateContext(context, resource);
resourceName = (String) expr.evaluate(new ReadonlyContext(context));
} catch (JexlException e) {
LOG.error("getResourceNameFromIndex(): error evaluating index-format [{}] as a Jexl Expression", m_parameters.get(PARAM_INDEX_FORMAT), e);
} finally {
if (resourceName == null) {
resourceName = resource.getInstance();
}
}
if ("true".equals(m_parameters.get(PARAM_CLEAN_OUTPUT)) && resourceName != null) {
resourceName = resourceName.replaceAll("\\s+", "_").replaceAll(":", "_").replaceAll("\\\\", "_").replaceAll("[\\[\\]]", "_").replaceAll("[|/]", "_").replaceAll("=", "").replaceAll("[_]+$", "").replaceAll("___", "_");
}
LOG.debug("getResourceNameFromIndex(): {}", resourceName);
return resourceName;
}
Aggregations