Package org.pentaho.reporting.libraries.formula

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


  public TypeValuePair evaluate(final FormulaContext context,
                                final ParameterCallback parameters) throws EvaluationException
  {
    if(parameters.getParameterCount() != 0)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    return RETURN_TRUE;
  }
View Full Code Here


    // Error or empty string, that's the question ..
    final Object raw1 = value1.getValue();
    final Object raw2 = value2.getValue();
    if (raw1 == null || raw2 == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    final String text1 = typeRegistry.convertToText(value1.getType(), raw1);
    final String text2 = typeRegistry.convertToText(value2.getType(), raw2);
    if (text1 == null && text2 == null)
    {
      throw new EvaluationException
          (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    if (text1 == null)
    {
      return new TypeValuePair(TextType.TYPE, text2);
View Full Code Here

  {
    final Type type = value1.getType();
    final Object val = value1.getValue();
    if (val == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
    }
   
    if (type.isFlagSet(Type.NUMERIC_TYPE))
    {
      final TypeRegistry typeRegistry = context.getTypeRegistry();
      // return the same as zero minus value.
      final Number number = typeRegistry.convertToNumber(type, val);
      if (number == null)
      {
        throw new EvaluationException
            (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
      }
      final BigDecimal value = NumberUtil.getAsBigDecimal(number);
      return new TypeValuePair(NumberType.GENERIC_NUMBER, ZERO.subtract(value));
    }

    if(val instanceof Number)
    {
      final BigDecimal value = NumberUtil.getAsBigDecimal((Number)val);
      if (value == null)
      {
        throw new EvaluationException
            (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
      }
      return new TypeValuePair(type, ZERO.subtract(value));
    }

    throw new EvaluationException
        (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
  }
View Full Code Here

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Object value1Raw = value1.getValue();
    final Object value2Raw = value2.getValue();
    if (value1Raw == null || value2Raw == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    final Type type1 = value1.getType();
    final Type type2 = value2.getType();
    final ExtendedComparator comparator = typeRegistry.getComparator(type1, type2);
View Full Code Here

                                final TypeValuePair value1) throws EvaluationException
  {
    if (value1 == null)
    {
      // This is fatal, but should never happen.
      throw new EvaluationException(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }
    return value1;
  }
View Full Code Here

      throws EvaluationException
  {
    if (bd2.signum() == 0)
    {
      // prevent a division by zero ..
      throw new EvaluationException(LibFormulaErrorValue.ERROR_ARITHMETIC_VALUE);
    }
    final BigDecimal divide = bd1.divide(bd2, LibFormulaBoot.GLOBAL_SCALE, BigDecimal.ROUND_HALF_UP);
    return NumberUtil.removeTrailingZeros(divide);
  }
View Full Code Here

    final Type type2 = value2.getType();
    final Object value1Raw = value1.getValue();
    final Object value2Raw = value2.getValue();
    if (value1Raw == null || value2Raw == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    final ExtendedComparator comparator = typeRegistry.getComparator(type1, type2);
    final int result = comparator.compare (type1, value1Raw, type2, value2Raw);
    if (evaluate(result))
View Full Code Here

    final TypeRegistry typeRegistry = context.getTypeRegistry();

    if (value1 == null || value2 == null)
    {
      // If this happens, then one of the implementations has messed up.
      throw new EvaluationException(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }

    final Object raw1 = value1.getValue();
    final Object raw2 = value2.getValue();
    if (raw1 == null || raw2 == null)
    {
      throw new EvaluationException (LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    final Number number1 = convertToNumber(typeRegistry, value1.getType(), raw1, ZERO);
    final Number number2 = convertToNumber(typeRegistry, value2.getType(), raw2, ZERO);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, evaluate(number1, number2));
View Full Code Here

      throws EvaluationException
  {
    final Object rawValue = value1.getValue();
    if (rawValue == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    final Type type = value1.getType();
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    if (type.isFlagSet(Type.NUMERIC_TYPE) == false &&
        type.isFlagSet(Type.ANY_TYPE) == false)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }

    // return the same as zero minus value.
    final Number number = typeRegistry.convertToNumber(type, rawValue);
    final BigDecimal value = NumberUtil.getAsBigDecimal(number);
View Full Code Here

    public TypeValuePair evaluate(final FormulaContext context,final ParameterCallback parameters)
            throws EvaluationException
    {
        if (parameters.getParameterCount() != 0)
        {
            throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
        }

        return new TypeValuePair(TextType.TYPE, context.getConfiguration().getConfigProperty(ReportEngineParameterNames.AUTHOR));
    }
View Full Code Here

TOP

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

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.