Package org.pentaho.reporting.libraries.formula

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


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

  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

  }

  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

    final String formulaExpression = extractFormula(formula);
    if (formulaExpression == null)
    {
      throw new ParseException("Formula is invalid");
    }
    return getReferences(new Formula(formulaExpression));
  }
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

    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);
          final Object evaluate = initFormula.evaluate();
          if (Boolean.TRUE.equals(failOnError))
          {
            if (evaluate instanceof ErrorValue)
            {
              throw new InvalidReportStateException(String.format
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

      {
        return tdf;
      }
    };
    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

    {
        try
        {
            final FormattedTextElement element = (FormattedTextElement) getNode();
            final FormulaExpression formulaExpression = element.getValueExpression();
            final Formula formula = formulaExpression.getCompiledFormula();
            final LValue lValue = formula.getRootReference();
            return isReferenceChanged(lValue);
        }
        catch (final ParseException e)
        {
            LOGGER.debug("Parse Exception", e);
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.