Package org.pentaho.reporting.libraries.formula.typing

Examples of org.pentaho.reporting.libraries.formula.typing.TypeRegistry


    }
    if (parameters.getParameterCount() > 3)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final String urlText = typeRegistry.convertToText(parameters.getType(0), parameters.getValue(0));
    if (urlText == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    String tabText = null;
    if (parameters.getParameterCount() > 1)
    {
      tabText = typeRegistry.convertToText(parameters.getType(1), parameters.getValue(1));
    }

    final ReportFormulaContext rfc = (ReportFormulaContext) context;
    if (StringUtils.isEmpty(tabText))
    {
      final DocumentMetaData documentMetaData = rfc.getProcessingContext().getDocumentMetaData();
      tabText = (String) documentMetaData.getBundleAttribute
          (ODFMetaAttributeNames.DublinCore.NAMESPACE, ODFMetaAttributeNames.DublinCore.TITLE);
      if (StringUtils.isEmpty(tabText))
      {
        final Object o = rfc.getDataRow().get("report.name");
        if (o != null)
        {
          tabText = String.valueOf(o);
        }
      }
      if (StringUtils.isEmpty(tabText))
      {
        final ResourceBundle bundle = ResourceBundle.getBundle
            ("org.pentaho.reporting.engine.classic.extensions.drilldown.messages");
        tabText = bundle.getString("UnnamedTab");
      }
    }

    final boolean tabActive;
    if (parameters.getParameterCount() == 3)
    {
      if (Boolean.FALSE.equals(typeRegistry.convertToLogical(parameters.getType(2), parameters.getValue(2))))
      {
        tabActive = false;
      }
      else
      {
View Full Code Here


    // 0: Configuration-indicator (gives the pattern indirectly) never the pattern itself
    // 1: the report-path
    // 2: the parameter as 2d-array (name value pairs)

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final String configIndicator = typeRegistry.convertToText(parameters.getType(0), parameters.getValue(0));
    String path;
    try
    {
      path = typeRegistry.convertToText(parameters.getType(1), parameters.getValue(1));
    }
    catch (EvaluationException ee)
    {
      if (LibFormulaErrorValue.ERROR_NA_VALUE.equals(ee.getErrorValue()))
      {
        path = null;
      }
      else
      {
        throw ee;
      }
    }
    final ArrayCallback parameter = typeRegistry.convertToArray(parameters.getType(2), parameters.getValue(2));

    final LinkCustomizer pattern = createLinkCustomizer(configIndicator);
    return new TypeValuePair(TextType.TYPE, pattern.format(context, configIndicator, path,
        computeParameterEntries(parameter, typeRegistry)));
  }
View Full Code Here

    if (parameterCount < 1)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final double value = typeRegistry.convertToNumber(parameters.getType(0), parameters.getValue(0)).doubleValue();
    boolean fixedSize = false;
    int precision = 0;

    // Value == 0? return
    if(value == 0)
        return new TypeValuePair(TextType.TYPE, "0");

    if (parameters.getParameterCount() > 1)
    {
      fixedSize = true;
      precision = typeRegistry.convertToNumber(parameters.getType(1), parameters.getValue(1)).intValue();
      if (parameters.getParameterCount() == 3)
      {
        final Boolean rawFixedSize = typeRegistry.convertToLogical(parameters.getType(2), parameters.getValue(2));
        fixedSize = rawFixedSize.booleanValue();
      }
    }

    final int log10 = computeLog10(value);
View Full Code Here

  public final TypeValuePair evaluate(final FormulaContext context,
                                      final TypeValuePair value1,
                                      final TypeValuePair value2)
      throws EvaluationException
  {
    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Type type1 = value1.getType();
    final Type type2 = value2.getType();
    final Object value1Raw = value1.getValue();
    final Object value2Raw = value2.getValue();
    if (value1Raw == null || value2Raw == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

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

  public TypeValuePair evaluate(final FormulaContext context,
                                final TypeValuePair value1, final TypeValuePair value2)
      throws EvaluationException
  {
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    final ExtendedComparator comparator =
        typeRegistry.getComparator(value1.getType(), value2.getType());
    final boolean result = comparator.isEqual
        (value1.getType(), value1.getValue(),
            value2.getType(), value2.getValue());

    if (result == false)
View Full Code Here

  public final TypeValuePair evaluate(final FormulaContext context,
                                      final TypeValuePair value1,
                                      final TypeValuePair value2)
      throws EvaluationException
  {
    final TypeRegistry typeRegistry = context.getTypeRegistry();

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

    {
      throw EvaluationException.getInstance(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 EvaluationException.getInstance(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);
    final BigDecimal percentage = NumberUtil.divide(value, HUNDRED);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, percentage);
  }
View Full Code Here

    if (parameters.getParameterCount() > 1)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }

    final TypeRegistry typeRegistry = context.getTypeRegistry();

    int type = 1; // default is Type 1
    if (parameters.getParameterCount() == 1)
    {
      final Number n = typeRegistry.convertToNumber(parameters.getType(0), parameters.getValue(0));
      if (n == null)
      {
        throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
      }
      type = n.intValue();
View Full Code Here

    final int parameterCount = parameters.getParameterCount();
    if (parameterCount < 1 || parameterCount > 2)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    final int length;
    if (parameterCount == 2)
    {
      final Number lengthVal = typeRegistry.convertToNumber(parameters.getType(1), parameters.getValue(1));
      if (lengthVal.doubleValue() < 0)
      {
        throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
      }
      length = lengthVal.intValue();
View Full Code Here

    if (parameters.getParameterCount() != 1)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Number n = typeRegistry.convertToNumber(parameters.getType(0), parameters.getValue(0));

    if (n == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.formula.typing.TypeRegistry

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.