Examples of TypeRegistry


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

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

    final Type textType = parameters.getType(0);
    final Object textValue = parameters.getValue(0);
    final Type searchTextType = parameters.getType(1);
    final Object searchTextValue = parameters.getValue(1);

    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);
    }
View Full Code Here

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

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

    final TypeRegistry typeRegistry = context.getTypeRegistry();

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

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

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

    final Type textType = parameters.getType(0);
    final Object textValue = parameters.getValue(0);

    final String text = typeRegistry.convertToText(textType, textValue);
    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

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

    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

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

    }
    if (parameters.getParameterCount() > 4)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    final String dateString = typeRegistry.convertToText(parameters.getType(0), parameters.getValue(0));
    final String pattern = typeRegistry.convertToText(parameters.getType(1), parameters.getValue(1));
    final Locale locale;
    if (parameters.getParameterCount() > 2)
    {
      final String localeText = typeRegistry.convertToText(parameters.getType(2), parameters.getValue(2));
      if (StringUtils.isEmpty(localeText))
      {
        locale = context.getLocalizationContext().getLocale();
      }
      else
      {
        locale = parseLocale(localeText);
      }
    }
    else
    {
      locale = context.getLocalizationContext().getLocale();
    }

    final TimeZone timeZone;
    if (parameters.getParameterCount() > 3)
    {
      final String timeZoneText = typeRegistry.convertToText(parameters.getType(3), parameters.getValue(3));
      timeZone = TimeZone.getTimeZone(timeZoneText);
    }
    else
    {
      timeZone = context.getLocalizationContext().getTimeZone();
View Full Code Here

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

    if(parameterCount == 0)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    BigDecimal last = null;
    for (int paramIdx = 0; paramIdx < parameterCount; paramIdx++)
    {
      final Type type = parameters.getType(paramIdx);
      final Object value = parameters.getValue(paramIdx);
      final Sequence sequence = typeRegistry.convertToNumberSequence(type, value, isStrictSequenceNeeded());

      while (sequence.hasNext())
      {
        final LValue rawValue = sequence.nextRawValue();
        if (rawValue == null)
        {
          throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
        }
        final TypeValuePair nextValue = rawValue.evaluate();
        final Number number = typeRegistry.convertToNumber(nextValue.getType(), nextValue.getValue());
        final BigDecimal next = NumberUtil.getAsBigDecimal(number);

        if(last == null)
        {
          last = next;
View Full Code Here

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

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

    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Date date1 = typeRegistry.convertToDate
        (parameters.getType(0), parameters.getValue(0));
    final Date date2 = typeRegistry.convertToDate
        (parameters.getType(1), parameters.getValue(1));

    if (date1 == null || date2 == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
View Full Code Here

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

    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
    final Type type1 = parameters.getType(0);
    final Object value1 = parameters.getValue(0);
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    String result = typeRegistry.convertToText(type1, value1);
    if (result == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
View Full Code Here

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

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

    final Type type1 = parameters.getType(0);
    final Object value1 = parameters.getValue(0);
    final Number number1 = typeRegistry.convertToNumber(type1, value1);
    if (number1 == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    final BigDecimal divided = NumberUtil.getAsBigDecimal(number1);
   
    final Type type2 = parameters.getType(1);
    final Object value2 = parameters.getValue(1);
    final Number number2 = typeRegistry.convertToNumber(type2, value2);
    if (number2 == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
   
View Full Code Here

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

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

    if (value == 0)
    {
      return new TypeValuePair(TextType.TYPE, "0 ");
    }

    boolean fixedSize = false;
    int precision = 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
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.