Package com.neemsoft.jmep

Examples of com.neemsoft.jmep.Expression


    return res;
  }

  private float doEvaluateCalculation(String calculation) throws ParseException {
    try {
      Expression exp = new Expression(calculation, env);
      Object result = exp.evaluate();
      if (result instanceof Double) {
        return ((Double) result).floatValue();
      } else if (result instanceof Integer) {
        return ((Integer) result).floatValue();
      } else throw new ArgumentParseException("Parse exception: expected Double or Integer, but got:"
View Full Code Here


   * @param condition The condition as a java script text
   * @return true if condition matches, false otherwhise
   */
  private boolean doEvaluateCondition(String condition) throws ParseException {
    try {
      Expression exp = new Expression(condition, env);
      Object result = exp.evaluate();
      if (result instanceof Double) {
        return (((Double) result).doubleValue() == 1.0) ? true : false;
      } else if (result instanceof Integer) {
        return (((Integer) result).intValue() == 1) ? true : false;
      } else return false;
View Full Code Here

    // CourseEnvironment ce = new CourseEnvironmentImpl(null);
    ConditionInterpreter interpreter = null; //new ConditionInterpreter(new TestUserCourseEnvironmentImpl());// ce);

    long start = System.currentTimeMillis();
    try {
      Expression exp = new Expression("(inGroup(\"blue\")|!inGroup(\"red\")) & now > date(\"09.03.2004 15:00\")", interpreter.env);
      Expression exp2 = new Expression("(9.99999 < 10) & (1000/2 > 200)", interpreter.env);

      for (int i = 0; i < 1000; i++) {
        exp = new Expression("(inGroup(\"blue\")|!inGroup(\"red\")) & now > date(\"09.03.2004 15:00\")", interpreter.env);
        interpreter.evaluateCondition(exp);
        exp2 = new Expression("(9.99999 < 10) & (1000/2 > 200)", interpreter.env);
        interpreter.evaluateCondition(exp2);
      }

    } catch (Exception e) {
      // just a timing test
View Full Code Here

       * CourseEditorEnv.validateConditionExpression(). Hence
       * syntaxTestExpression should never be called directly or in a non editor
       * environment.
       */
      String conditionString = condExpr.getExptressionString();
      Expression exp = new Expression(conditionString, env);
      exp.evaluate();
      Exception[] condExceptions = condExpr.getExceptions();
      ConditionErrorMessage[] cems = null;
      if (condExceptions != null && condExceptions.length > 0) {
        // create an error message from the first error in the expression
        cems=new ConditionErrorMessage[condExceptions.length];
View Full Code Here

   * @return Null if syntactically correct, error message otherwise.
   * @deprecated TODO: remove as it is no longer referenced, except test?
   */
  public ConditionErrorMessage syntaxTestCalculation(String expression) {
    try {
      Expression exp = new Expression(expression, env);
      exp.evaluate();
    } catch (Exception e) {
      return handleExpressionExceptions(e);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.neemsoft.jmep.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.