[rules-users] [MVEL] the data converter does not work

kapokfly ivan.jiang.ww at foxmail.com
Tue Dec 13 03:54:30 EST 2011


Can someone tell why the data converter does not work at all and what is the
reason we make the data converter to value assignment statement only? 

  public void testDataConverter() throws Exception {
    OptimizerFactory.setDefaultOptimizer(OptimizerFactory.SAFE_REFLECTIVE);

    DataConversion.addConversionHandler(Date.class, new MyDateConverter());

    Locale.setDefault(Locale.US);

    Cheese cheese = new Cheese();
    cheese.setUseBy(new
SimpleDateFormat("dd-MMM-yyyy").parse("10-Jul-1974"));

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("cheese", cheese);

    Serializable compiledExpression = MVEL.compileExpression("cheese.useBy
== '10-Jul-1974'");
    boolean result = MVEL.executeExpression(compiledExpression, variables,
Boolean.class);
    assertTrue(result);
  }


Here is what I can see from the code, at the end this method will be called,
would it be nice to allow the data converter here? 
    private static Boolean safeEquals(final Object val1, final Object val2)
{
        if (val1 != null) {
            return val1.equals(val2) ? Boolean.TRUE : Boolean.FALSE;
        }
        else return val2 == null || (val2.equals(val1) ? Boolean.TRUE :
Boolean.FALSE);
    }




-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-the-data-converter-does-not-work-tp3581797p3581797.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list