Package org.pentaho.reporting.libraries.formula.lvalues

Examples of org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair


    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Type type = parameters.getType(0);
    final Object value = parameters.getValue(0);

    final Date date1 = typeRegistry.convertToDate(type, value);
    return new TypeValuePair(DateTimeType.DATETIME_TYPE, date1);

  }
View Full Code Here


    final Object value1 = parameters.getValue(0);
    final Number result = context.getTypeRegistry().convertToNumber(type1, value1);

    final BigDecimal ret = compute(result);

    return new TypeValuePair(NumberType.GENERIC_NUMBER, ret);
  }
View Full Code Here

    for (int i = 0; i < chars.length; i++)
    {
      final char c = chars[i];
      convert(c, b);
    }
    return new TypeValuePair(TextType.TYPE, b.toString());
  }
View Full Code Here

      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    final double d = StrictMath.log(result.doubleValue());

    final BigDecimal divide = new BigDecimal(d).divide(LOG10BASE, LibFormulaBoot.GLOBAL_SCALE, BigDecimal.ROUND_HALF_UP);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, NumberUtil.removeTrailingZeros(divide));
  }
View Full Code Here

          break;
        }
      }
    }
    // Note that MID(T;1;Length) produces the same results as LEFT(T;Length).
    return new TypeValuePair(AnyType.ANY_ARRAY, retval.toArray());
  }
View Full Code Here

    final String text = typeRegistry.convertToText(textType, textValue);
    final String searchText = typeRegistry.convertToText(searchTextType, searchTextValue);
    if (searchText.length() == 0)
    {
      return new TypeValuePair(NumberType.GENERIC_NUMBER, 0);
    }

    int index = text.indexOf(searchText);
    if (index == -1)
    {
      return new TypeValuePair(NumberType.GENERIC_NUMBER, 0);
    }

    int occcounter = 0;
    while (index >= 0)
    {
      final int oldIndex = index + searchText.length();

      index = text.indexOf(searchText, oldIndex);
      occcounter += 1;
    }
    return new TypeValuePair(NumberType.GENERIC_NUMBER, occcounter);
  }
View Full Code Here

    final int dayOfWeek = gc.get(Calendar.DAY_OF_WEEK);
    // in java Sunday = 1 (= Type 1 of openformula)
    final int result = convertType(dayOfWeek, type);
    //noinspection UnpredictableBigDecimalConstructorCall
    return new TypeValuePair(NumberType.GENERIC_NUMBER, new BigDecimal((double)result));
  }
View Full Code Here

    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }

    final BigDecimal num = NumberUtil.getAsBigDecimal(result);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, num.abs());
  }
View Full Code Here

        }
      }
    }

    return new TypeValuePair(NumberType.GENERIC_NUMBER, new BigDecimal(count));
  }
View Full Code Here

  public TypeValuePair evaluate(final FormulaContext context,
                                final ParameterCallback parameters)
      throws EvaluationException
  {
    final TypeValuePair sum = sumFunction.evaluate(context, parameters);

    final Number n = context.getTypeRegistry().convertToNumber(sum.getType(), sum.getValue());
    if (n == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    final BigDecimal divident = NumberUtil.getAsBigDecimal(n);
    final BigDecimal divisor = new BigDecimal(parameters.getParameterCount());
    final BigDecimal avg = NumberUtil.divide(divident, divisor);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, avg);
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair

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.