Skip to end of metadata
Go to start of metadata

Custom Functions for DIH

It is possible to plug in custom functions into DIH. Implement an Evaluator and specify it in the data-config.xml . Following is an example of an evaluator which does a 'toLowerCase' on a String.

   <function name="toLowerCase" class="foo.LowerCaseFunctionEvaluator"/>
   <entity query="select * from table where name='${dih.functions.toLowerCase(dih.request.user)'">
    <!- ......field declarations......->

The implementation of LowerCaseFunctionEvaluator

  public class LowerCaseFunctionEvaluator extends Evaluator{
    public String evaluate(String expression, Context context) {
      List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());

      if (l.size() != 1) {
          throw new RuntimeException("'toLowerCase' must have only one parameter ");
      return l.get(0).toString().toLowerCase();


  • No labels