Exemplo n.º 1
0
 public boolean validate(Map<String, Object> context) {
   if (Strings.isNullOrEmpty(condition)) {
     return true;
   }
   String expr = condition + " ? true : false";
   return (Boolean) helper.eval(expr, context);
 }
Exemplo n.º 2
0
  private Object handleCall(Map<String, Object> context, String expr, Injector injector) {
    if (Strings.isNullOrEmpty(expr)) {
      return null;
    }

    try {

      String className = expr.split("\\:")[0];
      String method = expr.split("\\:")[1];

      Class<?> klass = Class.forName(className);
      Object object = injector.getInstance(klass);

      Pattern p = Pattern.compile("(\\w+)\\((.*?)\\)");
      Matcher m = p.matcher(method);

      if (!m.matches()) return null;

      String methodName = m.group(1);
      String params = "[" + m.group(2) + "] as Object[]";
      Object[] arguments = (Object[]) helper.eval(params, context);

      return InvokerHelper.invokeMethod(object, methodName, arguments);
    } catch (Exception e) {
      System.err.println("EEE: " + e);
      return null;
    }
  }
Exemplo n.º 3
0
 private Object handleGroovy(Map<String, Object> context) {
   if (Strings.isNullOrEmpty(expression)) {
     return context.get(column);
   }
   return helper.eval(expression, context);
 }