Examples of Formula


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

      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

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

    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

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

    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

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

    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

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

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

  }

  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

Examples of org.projectforge.excel.Formula

    final int firstDataRowNumber = sheet.getRowCounter() + 1;
    final DayHolder current = today.clone();
    PropertyMapping mapping = new PropertyMapping();
    mapping.add("balanceExpected", BigDecimal.ZERO);
    mapping.add("balance", new Formula("D" + firstDataRowNumber));
    sheet.addRow(mapping.getMapping(), 0);

    for (int i = 0; i < credits.length; i++) {
      final int rowNumber = sheet.getRowCounter();
      mapping.add("date", current);
      mapping.add("creditsExpected", NumberHelper.isZeroOrNull(creditsExpected[i]) == true ? "" : creditsExpected[i]);
      mapping.add("debitsExpected", NumberHelper.isZeroOrNull(debitsExpected[i]) == true ? "" : debitsExpected[i]);
      mapping.add("balanceExpected", new Formula("D" + rowNumber + "+SUM(B" + rowNumber + ":C" + rowNumber + ")"));
      mapping.add("credits", NumberHelper.isZeroOrNull(credits[i]) == true ? "" : credits[i]);
      mapping.add("debits", NumberHelper.isZeroOrNull(debits[i]) == true ? "" : debits[i]);
      mapping.add("balance", new Formula("G" + rowNumber + "+SUM(E" + rowNumber + ":F" + rowNumber + ")"));
      sheet.addRow(mapping.getMapping(), 0);
      current.add(Calendar.DAY_OF_YEAR, 1);
    }
    mapping = new PropertyMapping();
    mapping.add("creditsExpected", new Formula("SUM(B" + firstDataRowNumber + ":B" + sheet.getRowCounter() + ")"));
    mapping.add("debitsExpected", new Formula("SUM(C" + firstDataRowNumber + ":C" + sheet.getRowCounter() + ")"));
    mapping.add("balanceExpected", new Formula("D" + firstDataRowNumber + "+SUM(B" + firstDataRowNumber + ":C" + sheet.getRowCounter() + ")"));
    mapping.add("credits", new Formula("SUM(E" + firstDataRowNumber + ":E" + sheet.getRowCounter() + ")"));
    mapping.add("debits", new Formula("SUM(F" + firstDataRowNumber + ":F" + sheet.getRowCounter() + ")"));
    mapping.add("balance", new Formula("G" + firstDataRowNumber + "+SUM(E" + firstDataRowNumber + ":F" + sheet.getRowCounter() + ")"));
    sheet.addRow(mapping.getMapping(), 0);
  }
View Full Code Here

Examples of org.renjin.stats.internals.models.Formula

    SEXP expr = tree.getElementAsSEXP(0);
    return expr;
  }
 
  private Formula formula(String response, List<Term> terms) {
    return new Formula(Symbol.get(response), 1, terms);
  }
View Full Code Here

Examples of org.renjin.stats.internals.models.Formula

  private Formula formula(String response, List<Term> terms) {
    return new Formula(Symbol.get(response), 1, terms);
  }
 
  private Formula formula(String response, int intercept, List<Term> terms) {
    return new Formula(Symbol.get(response), intercept, terms);
  }
View Full Code Here

Examples of org.sonar.api.measures.Formula

    org.sonar.api.measures.Metric m = findMetricOrFail(measure.metric().key());
    org.sonar.api.measures.Measure measureToSave = new org.sonar.api.measures.Measure(m);
    setValueAccordingToMetricType(newMeasure, m, measureToSave);
    measureToSave.setFromCore(measure.isFromCore());
    if (newMeasure.inputFile() != null) {
      Formula formula = newMeasure.metric() instanceof org.sonar.api.measures.Metric ?
        ((org.sonar.api.measures.Metric) newMeasure.metric()).getFormula() : null;
      if (formula instanceof SumChildDistributionFormula
        && !Scopes.isHigherThanOrEquals(Scopes.FILE, ((SumChildDistributionFormula) formula).getMinimumScopeToPersist())) {
        measureToSave.setPersistenceMode(PersistenceMode.MEMORY);
      }
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.