public void setParam(String key, String value) { if (value.startsWith("expr:")) { value = value.substring(5).trim(); if (value.contains("@{")) { params.put(key, Scripting.newTemplate(value)); } else { params.put(key, Scripting.newExpression(value)); } } else { params.put(key, value); } }
public ChainExceptionFilter(String id, String value) { this.id = id; if (value.startsWith("expr:")) { value = value.substring(5).trim(); // Unescape xml checking value = StringEscapeUtils.unescapeXml(value); if (value.contains("@{")) { this.value = Scripting.newTemplate(value); } else { this.value = Scripting.newExpression(value); } } }
public OperationParameters set(String key, Object valueRef) { if (valueRef instanceof String) { if (((String) valueRef).startsWith("expr:")) { valueRef = ((String) valueRef).substring(5).trim(); // Unescape xml checking valueRef = StringEscapeUtils.unescapeXml(((String) valueRef)); if (((String) valueRef).contains("@{")) { params.put(key, Scripting.newTemplate(((String) valueRef))); } else { params.put(key, Scripting.newExpression(((String) valueRef))); } return this; } } params.put(key, valueRef); return this; }
public ChainExceptionFilter(AutomationFilterDescriptor automationFilterDescriptor) { id = automationFilterDescriptor.getId(); String value = automationFilterDescriptor.getValue(); if (value.startsWith("expr:")) { value = value.substring(5).trim(); // Unescape xml checking value = StringEscapeUtils.unescapeXml(value); if (value.contains("@{")) { this.value = Scripting.newTemplate(value); } else { this.value = Scripting.newExpression(value); } } }
protected <T> T valueOrExpression(Class<T> klass, String v, OperationContext context, String kind) throws DocumentRouteException { if (!v.startsWith(EXPR_PREFIX)) { return (T) v; } v = v.substring(EXPR_PREFIX.length()).trim(); Expression expr; if (v.contains(TEMPLATE_START)) { expr = Scripting.newTemplate(v); } else { expr = Scripting.newExpression(v); } Object res = null; try { res = expr.eval(context); // stupid eval() method throws generic Exception } catch (RuntimeException e) { throw new DocumentRouteException("Error evaluating expression: " + v, e); } if (!(klass.isAssignableFrom(res.getClass()))) { throw new DocumentRouteException( kind + " of node '" + getId() + "' of graph '" + graph.getName() + "' does not evaluate to " + klass.getSimpleName() + " but " + res.getClass().getName() + ": " + v); } return (T) res; }
String value = param.value.substring(5); if (value.contains("@{")) { params.set(param.name, Scripting.newTemplate(value)); } else { params.set(param.name, Scripting.newExpression(value));