Package org.pentaho.reporting.libraries.formula

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


      }


      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);
      }
View Full Code Here


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

        errorTextHolder.setText(Messages.getInstance().getString("FormulaEditorDialog.ShortErrorNoFormulaContext"));
        errorTextHolder.setToolTipText(Messages.getInstance().getString("FormulaEditorDialog.ErrorNoFormulaContext"));
        return;
      }
      final Formula formula = new Formula(formulaText);
      formula.initialize(formulaContext);
      final TypeValuePair pair = formula.evaluateTyped();

      if (pair.getValue() instanceof LibFormulaErrorValue)
      {
        errorTextHolder.setText(Messages.getInstance().getString("FormulaEditorDialog.ShortEvaluationError"));
View Full Code Here

  {
    final Formula f = new Formula("IF(NOT(TRUE()));\"Testing\"; \"Other\"");

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

    final LValue rootReference = f.getRootReference();
    print(rootReference, 0);
  }
View Full Code Here

    // check whether the used functions or references are actually valid.
    final Formula f = new Formula(formula);

    // 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);
View Full Code Here

  }

  public void testRowsInlineArrays() throws Exception
  {
    final Formula formula = new Formula("{3|2|1}");
    formula.initialize(context);
    final TypeValuePair evaluation = formula.evaluateTyped();
    assertNotNull(evaluation);
    assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));

    final ArrayCallback table = (ArrayCallback) evaluation.getValue();
View Full Code Here

  }

  public void testColumnsInlineArrays() throws Exception
  {
    final Formula formula = new Formula("{3;2;1}");
    formula.initialize(context);
    final TypeValuePair evaluation = formula.evaluateTyped();
    assertNotNull(evaluation);
    assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));

    final ArrayCallback table = (ArrayCallback) evaluation.getValue();
View Full Code Here

  }

  public void testInlineArrays() throws Exception
  {
    final Formula formula = new Formula("{3;2;1|2;4;6}");
    formula.initialize(context);

    final TypeValuePair evaluation = formula.evaluateTyped();
    assertNotNull(evaluation);
    assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));
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);

  }
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);

  }
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.