Package org.pentaho.reporting.libraries.formula

Examples of org.pentaho.reporting.libraries.formula.Formula.evaluate()



      final String formula = computeFormula(configIndicator);
      final Formula compiledFormula = new Formula(formula);
      compiledFormula.initialize(new ReportFormulaContext(formulaContext, expressionRuntime));
      final Object o = compiledFormula.evaluate();
      if (o instanceof ErrorValue)
      {
        throw EvaluationException.getInstance((ErrorValue) o);
      }
      if (o == null)
View Full Code Here


        final ReportFormulaContext context = new ReportFormulaContext
            (getFormulaContext(), expressionRuntime);
        try
        {
          initFormula.initialize(context);
          return initFormula.evaluate();
        }
        finally
        {
          context.close();
        }
View Full Code Here

    // connects the parsed formula to the context. The context provides the
    // operator and function implementations and resolves the references.
    f.initialize(new DemoFormulaContext());

    final Object o = f.evaluate();
    JOptionPane.showMessageDialog(null, "The result is " + o,
        "Result", JOptionPane.INFORMATION_MESSAGE);

    System.exit(0);
  }
View Full Code Here

  public void testInvalidInlineArrays() throws Exception
  {
    final Formula formula = new Formula("{3;2;1|2;6}");
    formula.initialize(context);
    final Object evaluate = formula.evaluate();
    assertEquals(evaluate, LibFormulaErrorValue.ERROR_ILLEGAL_ARRAY_VALUE);

  }

  public void testInvalidInlineArrays2() throws EvaluationException, ParseException
View Full Code Here

  public void testInvalidInlineArrays2() throws EvaluationException, ParseException
  {
    final Formula formula = new Formula("{3;1|2;6;5;6}");
    formula.initialize(context);
    final Object evaluate = formula.evaluate();
    assertEquals(evaluate, LibFormulaErrorValue.ERROR_ILLEGAL_ARRAY_VALUE);

  }

  public void testEmptyArray() throws EvaluationException, ParseException
View Full Code Here

  public void testEmptyArray() throws EvaluationException, ParseException
  {
    final Formula formula = new Formula("{}");
    formula.initialize(context);
    final Object evaluate = formula.evaluate();
    assertTrue(evaluate instanceof StaticArrayCallback);
    StaticArrayCallback sc = (StaticArrayCallback) evaluate;
    assertEquals(0, sc.getColumnCount());
    assertEquals(0, sc.getRowCount());
View Full Code Here

  public void testDebugDates() throws Exception
  {
    Formula formula = null;
    formula = new Formula("DATE(2005;1;31)");
    formula.initialize(getContext());
    Date eval = (Date) formula.evaluate();
    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    System.out.println(eval.getClass().getName() + ":" + df.format(eval) + ";" + eval.getTime());

    final Date date = (Date) getContext().resolveReference(".C7");
    System.out.println(df.format(date) + ";" + date.getTime());
View Full Code Here

        final ReportFormulaContext context = new ReportFormulaContext
            (getFormulaContext(), expressionRuntime);
        try
        {
          initFormula.initialize(context);
          final Object evaluate = initFormula.evaluate();
          if (Boolean.TRUE.equals(failOnError))
          {
            if (evaluate instanceof ErrorValue)
            {
              throw new InvalidReportStateException(String.format
View Full Code Here

      }
    };
    ReportFormulaContext fc = new ReportFormulaContext(new DefaultFormulaContext(), rt);
    final Formula f = new Formula("MULTIVALUEQUERY(\"query\"; \"Column\"; 0; 5)");
    f.initialize(fc);
    final Object v = f.evaluate();
    Assert.assertNotNull(v);
    Assert.assertTrue(v.getClass().isArray());
    Assert.assertEquals(5, Array.getLength(v));
  }
}
View Full Code Here

  public Object compute(final FormulaContext formulaContext) throws EvaluationException, ParseException
  {
    Formula f = new Formula(FormulaUtil.extractFormula(formula));
    f.initialize(formulaContext);
    return f.evaluate();
  }

  public boolean equals(final Object o)
  {
    if (this == o)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.