Examples of TypeValuePair


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

      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }

    if (s == null)
    {
      return new TypeValuePair(TextType.TYPE, "");
    }
    final String encodingResult;
    if (parameterCount > 1)
    {
      final Object urlEncode = context.getTypeRegistry().convertToLogical(parameters.getType(1), parameters.getValue(1));
      if (Boolean.FALSE.equals(urlEncode))
      {
        return new TypeValuePair(TextType.TYPE, s);
      }

      if(parameterCount == 3)
      {
        final Type encodingType = parameters.getType(2);
        final Object encodingValue = parameters.getValue(2);
        encodingResult = context.getTypeRegistry().convertToText(encodingType, encodingValue);
        if(encodingResult == null)
        {
          throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
        }
      }
      else
      {
        encodingResult = context.getConfiguration().getConfigProperty
          ("org.pentaho.reporting.libraries.formula.URLEncoding", "ISO-8859-1");
      }
    }
    else
    {
      encodingResult = context.getConfiguration().getConfigProperty
        ("org.pentaho.reporting.libraries.formula.URLEncoding", "ISO-8859-1");
    }

    try
    {
      return new TypeValuePair(TextType.TYPE, URLEncoder.encode(s, encodingResult));

    }
    catch(final UnsupportedEncodingException use)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
View Full Code Here

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

    final String fieldName = context.getTypeRegistry().convertToText(parameters.getType(0), parameters.getValue(0));

    final ReportFormulaContext rfc = (ReportFormulaContext) context;
    final ReportEnvironment reportEnvironment = rfc.getProcessingContext().getEnvironment();
    return new TypeValuePair(AnyType.TYPE, reportEnvironment.getEnvironmentProperty(fieldName));
  }
View Full Code Here

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

    }
    final DefaultDataAttributeContext attributeContext =
        new DefaultDataAttributeContext(rfc.getProcessingContext().getOutputProcessorMetaData(),
            rfc.getLocalizationContext().getLocale());
    final Object o = data.getMetaAttribute(metaNamespace, metaName, type, attributeContext);
    return new TypeValuePair(AnyType.TYPE, o);
  }
View Full Code Here

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

    {
      queryTimeOut = 0;
    }

    final Object result = performQuery(rfc, query, resultColumn, queryTimeOut);
    return new TypeValuePair(AnyType.TYPE, result);
  }
View Full Code Here

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

      {
        final String namespace = namespaces[i];
        final Object attribute = data.getBundleAttribute(namespace, metaName);
        if (attribute != null)
        {
          return new TypeValuePair(AnyType.TYPE, attribute);
        }
      }
    }
    else
    {
      final String metaNamespace = context.getTypeRegistry().convertToText(parameters.getType(0), parameters.getValue(0));
      final String metaName = context.getTypeRegistry().convertToText(parameters.getType(1), parameters.getValue(1));
      {
        final Object o = data.getBundleAttribute(metaNamespace, metaName);
        return new TypeValuePair(AnyType.TYPE, o);
      }
    }

    throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_NA_VALUE);
  }
View Full Code Here

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

    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);

    // index will allow us to find the the index of the suffix to use
    final int index = (int) (Math.floor(log10 / 3.0) + OFFSET);
    if (index < 0 || index >= SUFFIXES.length)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }

    // Find the adequate precision. % operator behaves badly in negative results, so we need to make it work as expected
    final int roundPrecision = fixedSize ? (log10 - precision) : (log10 - (precision + (3 + log10 % 3) % 3));

    // Round the value
    final double roundingScale = Math.pow(10, roundPrecision);
    final double rounded = Math.round(value / roundingScale) * roundingScale;

    // Get it's eng format. Get it as string without trailing 0's
    final double outputValue = rounded / Math.pow(10, Math.floor(log10 / 3.0) * 3);
    final int outputValueDecimalPlaces = Math.max (1, computeLog10(outputValue));
   
    final Locale locale = context.getLocalizationContext().getLocale();
    final NumberFormat decimalFormat = createDecimalFormat(fixedSize, outputValueDecimalPlaces, precision, locale);
    final String result = decimalFormat.format(outputValue) + SUFFIXES[index];
    return new TypeValuePair(TextType.TYPE, result);
  }
View Full Code Here

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

        {
          b.append(s);
        }
      }

      return new TypeValuePair(TextType.TYPE, b.toString());

    }
    catch (final UnsupportedEncodingException use)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
View Full Code Here

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

        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

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

        if (parameters.getParameterCount() != 0)
        {
            throw new EvaluationException(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
        }

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

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

        errorTextHolder.setToolTipText(Messages.getInstance().getString("FormulaEditorDialog.ErrorNoFormulaContext"));
        return;
      }
      final Formula formula = new Formula(formulaText);
      formula.initialize(formulaContext);
      final TypeValuePair pair = formula.evaluateTyped();

      if (pair.getValue() instanceof LibFormulaErrorValue)
      {
        errorTextHolder.setText(Messages.getInstance().getString("FormulaEditorDialog.ShortEvaluationError"));
        errorTextHolder.setToolTipText(Messages.getInstance().getString("FormulaEditorDialog.EvaluationError"));
      }
      else
      {
        errorTextHolder.setToolTipText(null);
        errorTextHolder.setText(Messages.getInstance().getString("FormulaEditorDialog.EvaluationResult", String.valueOf(pair.getValue())));
      }
      errorIconHolder.setIcon(null);
    }
    catch (ParseException pe)
    {
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.