@Test public void testFunctionNamespace1() throws Exception { final VariableResolverImpl resolver = new VariableResolverImpl(); resolver.context = new ContextImpl(null,resolver, null, Context.FULL_DUMP, Collections.EMPTY_MAP, null,null); final List<Map<String ,String >> l = new ArrayList<Map<String, String>>(); Map<String ,String > m = new HashMap<String, String>(); m.put("name","test"); m.put("class",E.class.getName()); l.add(m); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); DateMathParser dmp = new DateMathParser(TimeZone.getDefault(), Locale.getDefault()); resolver.addNamespace("dataimporter.functions", EvaluatorBag .getFunctionsNamespace(l,null)); String s = resolver .replaceTokens("${dataimporter.functions.formatDate('NOW/DAY','yyyy-MM-dd HH:mm')}"); Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd HH:mm") .format(dmp.parseMath("/DAY")), s); Assert.assertEquals("Hello World", resolver .replaceTokens("${dataimporter.functions.test('TEST')}")); }
public abstract String replaceTokens(String template);
VariableResolver { public abstract String replaceTokens(String template); }
VariableResolver { public abstract String replaceTokens(String template);  }
VariableResolver { public abstract String replaceTokens(String template);  abstract Object resolve(String name); abstract String replaceTokens(String template); }
VariableResolver { public abstract String replaceTokens(String template);  abstract Object resolve(String name); abstract String replaceTokens(String template);  }