Java Code Examples for org.codehaus.janino.ExpressionEvaluator#evaluate()

The following examples show how to use org.codehaus.janino.ExpressionEvaluator#evaluate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestClassCompilationTypes.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private int jdk() throws Exception{
  // Compile the expression once; relatively slow.
  ExpressionEvaluator ee = new ExpressionEvaluator("c > d ? c : d", // expression
      int.class, // expressionType
      new String[] { "c", "d" }, // parameterNames
      new Class[] { int.class, int.class } // parameterTypes
  );

  // Evaluate it with varying parameter values; very fast.
  return  (Integer) ee.evaluate(new Object[] { // parameterValues
      new Integer(10), new Integer(11), });
}
 
Example 2
Source File: TaxiQuerySolution.java    From flink-training-exercises with Apache License 2.0 5 votes vote down vote up
private boolean evaluateBooleanExpression(ExpressionEvaluator ee, TaxiRide ride, long watermark) throws InvocationTargetException {
	boolean result= false;
	if (ee != null) {
		result = (boolean) ee.evaluate(new Object[] { ride, watermark });
	}
	return result;
}
 
Example 3
Source File: TaxiQueryExercise.java    From flink-training-exercises with Apache License 2.0 5 votes vote down vote up
private boolean evaluateBooleanExpression(ExpressionEvaluator ee, TaxiRide ride, long watermark) throws InvocationTargetException {
	boolean result= false;
	if (ee != null) {
		result = (boolean) ee.evaluate(new Object[] { ride, watermark });
	}
	return result;
}