Package org.jfree.formula.lvalues

Examples of org.jfree.formula.lvalues.TypeValuePair


    if(result == null)
    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }

    return new TypeValuePair(TextType.TYPE, result.toLowerCase(context.getLocalizationContext().getLocale()));
  }
View Full Code Here


      formula.initialize(context);
    } catch (EvaluationException e)
    {
      Assert.fail("Initialization Error", e);
    }
    final TypeValuePair evaluation = formula.evaluateTyped();
    Assert.assertNotNull(evaluation);
    Assert.assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));
   
    final ArrayCallback table = (ArrayCallback)evaluation.getValue();
    Assert.assertEquals(table.getColumnCount(), 1);
    Assert.assertEquals(table.getRowCount(), 3);
  }
View Full Code Here

      formula.initialize(context);
    } catch (EvaluationException e)
    {
      Assert.fail("Initialization Error", e);
    }
    final TypeValuePair evaluation = formula.evaluateTyped();
    Assert.assertNotNull(evaluation);
    Assert.assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));
   
    final ArrayCallback table = (ArrayCallback)evaluation.getValue();
    Assert.assertEquals(table.getColumnCount(), 3);
    Assert.assertEquals(table.getRowCount(), 1);
  }
View Full Code Here

      formula.initialize(context);
    } catch (EvaluationException e)
    {
      Assert.fail("Initialization Error", e);
    }
    final TypeValuePair evaluation = formula.evaluateTyped();
    Assert.assertNotNull(evaluation);
    Assert.assertTrue(evaluation.getType().isFlagSet(Type.ARRAY_TYPE));
   
    final ArrayCallback table = (ArrayCallback)evaluation.getValue();
    Assert.assertEquals(table.getColumnCount(), 3);
    Assert.assertEquals(table.getRowCount(), 2);
  }
View Full Code Here

  {
    // we expect strings and will check, whether the reference for theses
    // strings is dirty.
    if (context instanceof ReportFormulaContext == false)
    {
      return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
          (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
    }

    final ReportFormulaContext reportFormulaContext =
        (ReportFormulaContext) context;
    final Object declaringElement = reportFormulaContext.getDeclaringElement();
    if (declaringElement instanceof Element == false)
    {
      return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
          (LibFormulaErrorValue.ERROR_REFERENCE_NOT_RESOLVABLE));
    }

    final Element element = (Element) declaringElement;

    if (parameters.getParameterCount() == 1)
    {
      final String value = (String) parameters.getValue(0);
      return new TypeValuePair(AnyType.TYPE, element.getAttribute(value));
    }
    else if (parameters.getParameterCount() == 2)
    {
      final String namespace = (String) parameters.getValue(0);
      final String attrName = (String) parameters.getValue(1);
      return new TypeValuePair(AnyType.TYPE,
          element.getAttribute(namespace, attrName));
    }
    return new TypeValuePair(ErrorType.TYPE, new LibFormulaErrorValue
        (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT));
  }
View Full Code Here

  public TypeValuePair evaluateTyped ()
  {
    try
    {
      final TypeValuePair typeValuePair = rootReference.evaluate();
      if (typeValuePair == null)
      {
        // Should no longer happen..
        return new TypeValuePair
            (ErrorType.TYPE, LibFormulaErrorValue.ERROR_NA_VALUE);
      }
      if(typeValuePair.getType().isFlagSet(Type.ERROR_TYPE))
      {
        Log.debug ("Error: " + typeValuePair.getValue());
      }
      return typeValuePair;
    }
    catch(EvaluationException ee)
    {
      return new TypeValuePair(ErrorType.TYPE, ee.getErrorValue());
    }
    catch (Exception e)
    {
      Log.warn ("Evaluation failed unexpectedly: ", e);
      return new TypeValuePair(ErrorType.TYPE, LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }
  }
View Full Code Here

      throw new EvaluationException
          (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    if (text1 == null)
    {
      return new TypeValuePair(TextType.TYPE, text2);
    }
    if (text2 == null)
    {
      return new TypeValuePair(TextType.TYPE, text1);
    }

    return new TypeValuePair(TextType.TYPE, text1 + text2);
  }
View Full Code Here

    {
      final TypeRegistry typeRegistry = context.getTypeRegistry();
      // return the same as zero minus value.
      final Number number = typeRegistry.convertToNumber(type, val);
      final BigDecimal value = getAsBigDecimal(number);
      return new TypeValuePair(type, ZERO.subtract(value));
    }

    if(val instanceof Number)
    {
      final BigDecimal value = getAsBigDecimal((Number)val);
      return new TypeValuePair(type, ZERO.subtract(value));
    }

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

      throw new EvaluationException (LibFormulaErrorValue.ERROR_NA_VALUE);
    }

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

    // return the same as zero minus value.
    final Number number = typeRegistry.convertToNumber(type, rawValue);
    final BigDecimal value = OperatorUtility.getAsBigDecimal(number);
    final BigDecimal divide = value.divide(HUNDRED, value.scale()+2,BigDecimal.ROUND_HALF_UP);
    return new TypeValuePair(type, divide);
  }
View Full Code Here

TOP

Related Classes of org.jfree.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.