Package org.pentaho.reporting.libraries.formula

Examples of org.pentaho.reporting.libraries.formula.Formula


                new DefaultTableModel(), -1, new DefaultProcessingContext());
      }


      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


    try
    {
      if (compiledFormula == null)
      {
        compiledFormula = new Formula(formulaExpression);
      }

      final ExpressionRuntime expressionRuntime = getRuntime();

      final ReportFormulaContext context =
View Full Code Here

    try
    {
      if (initial != null)
      {
        final ExpressionRuntime expressionRuntime = getRuntime();
        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

    try
    {
      if (compiledFormula == null)
      {
        compiledFormula = new Formula(formulaExpression);
      }
      final ExpressionRuntime expressionRuntime = getRuntime();
      final ReportFormulaContext context =
          new ReportFormulaContext(getFormulaContext(), expressionRuntime);
      try
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"));
        errorTextHolder.setToolTipText(Messages.getInstance().getString("FormulaEditorDialog.EvaluationError"));
View Full Code Here

public class FormulaParsePosition
{
  public static void main(String[] args) throws EvaluationException, ParseException
  {
    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

      return;
    }

    // first parse the formula. This checks the general syntax, but does not
    // 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);

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

    LibFormulaBoot.getInstance().start();
  }

  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();
    assertEquals(table.getColumnCount(), 1);
View Full Code Here

    assertEquals(table.getRowCount(), 3);
  }

  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();
    assertEquals(table.getColumnCount(), 3);
View Full Code Here

    assertEquals(table.getRowCount(), 1);
  }

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

    final ArrayCallback table = (ArrayCallback) evaluation.getValue();
    assertEquals(table.getColumnCount(), 3);
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.formula.Formula

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.