use of org.apache.commons.jexl2.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.jexl2.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.jexl2.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;
}
use of org.apache.commons.jexl2.JexlException in project traccar by tananaev.
the class ComputedAttributesHandler method handlePosition.
@Override
protected Position handlePosition(Position position) {
Collection<Attribute> attributes = attributesManager.getItems(attributesManager.getAllDeviceItems(position.getDeviceId()));
for (Attribute attribute : attributes) {
if (attribute.getAttribute() != null) {
Object result = null;
try {
result = computeAttribute(attribute, position);
} catch (JexlException error) {
LOGGER.warn("Attribute computation error", error);
}
if (result != null) {
try {
switch(attribute.getType()) {
case "number":
Number numberValue = (Number) result;
position.getAttributes().put(attribute.getAttribute(), numberValue);
break;
case "boolean":
Boolean booleanValue = (Boolean) result;
position.getAttributes().put(attribute.getAttribute(), booleanValue);
break;
default:
position.getAttributes().put(attribute.getAttribute(), result.toString());
}
} catch (ClassCastException error) {
LOGGER.warn("Attribute cast error", error);
}
}
}
}
return position;
}
use of org.apache.commons.jexl2.JexlException in project easy-rules by j-easy.
the class JexlAction method execute.
@Override
public void execute(Facts facts) {
Objects.requireNonNull(facts, "facts cannot be null");
MapContext ctx = new MapContext(facts.asMap());
try {
compiledScript.execute(ctx);
} catch (JexlException e) {
LOGGER.error("Unable to execute expression: '" + expression + "' on facts: " + facts, e);
throw e;
}
}
Aggregations