Examples of TypeRegistry


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 textType1 = parameters.getType(0);
    final Object textValue1 = parameters.getValue(0);
    final Type textType2 = parameters.getType(1);
    final Object textValue2 = parameters.getValue(1);

    final String text = typeRegistry.convertToText(textType1, textValue1);
    final String substring = typeRegistry.convertToText(textType2, textValue2);

    return text.contains(substring) ? RETURN_TRUE : RETURN_FALSE;
  }
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 textType1 = parameters.getType(0);
    final Object textValue1 = parameters.getValue(0);
    final Type patternType = parameters.getType(1);
    final Object patternValue = parameters.getValue(1);

    final String text = typeRegistry.convertToText(textType1, textValue1);

    String regex = typeRegistry.convertToText(patternType, patternValue);

    // replace any * or % with .*
    regex = regex.replaceAll("\\*", ".*").replaceAll("%", ".*");

    final Pattern p = Pattern.compile(regex);
View Full Code Here

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

    if(length < 2)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_ARGUMENTS_VALUE);
    }
   
    final TypeRegistry typeRegistry = context.getTypeRegistry();
    final Object value1Raw = parameters.getValue(0);
    final Type type1 = parameters.getType(0);   
    for (int i = 1; i < parameters.getParameterCount(); i++) {
      final Object value2Raw = parameters.getValue(i);
      if (value1Raw == null || value2Raw == null)
      {
        throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_NA_VALUE);
      }

      final Type type2 = parameters.getType(i);
      final ExtendedComparator comparator = typeRegistry.getComparator(type1, type2);
      final boolean result = comparator.isEqual (type1, value1Raw, type2, value2Raw);
      if (result)
      {
        return RETURN_TRUE;
      }
View Full Code Here

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 formatCode = typeRegistry.convertToText
        (parameters.getType(2), parameters.getValue(2));

    if (formatCode == null || "".equals(formatCode))
    {
      throw EvaluationException.getInstance(
          LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }

    long days = computeDays(parameters, typeRegistry);

    if (DateDifFunction.DAYS_CODE.equals(formatCode))
    {
      return new TypeValuePair(NumberType.GENERIC_NUMBER, new BigDecimal(days));
    }

    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

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

    // Error or empty string, that's the question ..
    final Object raw1 = value1.getValue();
    final Object raw2 = value2.getValue();
    if (raw1 == null || raw2 == null)
    {
      throw EvaluationException.getInstance(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 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_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 EvaluationException.getInstance
            (LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
      }
View Full Code Here

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

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

    final Type type1 = value1.getType();
    final Type type2 = value2.getType();
    final ExtendedComparator comparator = typeRegistry.getComparator(type1, type2);
    final boolean result = comparator.isEqual (type1, value1Raw, type2, value2Raw);
    if (result)
    {
      return RETURN_TRUE;
    }
View Full Code Here

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

        {
          return result;
        }

        // lets do some type checking, right?
        final TypeRegistry typeRegistry = function.getContext().getTypeRegistry();
        final TypeValuePair converted = typeRegistry.convertTo(paramType, result);
        if (converted == null)
        {
          if (logger.isDebugEnabled())
          {
            logger.debug("Failed to evaluate parameter " + pos + " on function " + function);
View Full Code Here

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

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

    final Type searchType = parameters.getType(0);
    final Object searchValue = parameters.getValue(0);
    final Type textType = parameters.getType(1);
    final Object textValue = parameters.getValue(1);
    Type indexType = null;
    Object indexValue = null;

    if (parameterCount == 3)
    {
      indexType = parameters.getType(2);
      indexValue = parameters.getValue(2);

      if (indexType == null || indexValue == null)
      {
        throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_MISSING_ARGUMENT_VALUE);
      }
    }

    final String search = typeRegistry.convertToText(searchType, searchValue);
    final String text = typeRegistry.convertToText(textType, textValue);

    if (search == null || text == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }
    int indexFrom = 0;

    if (indexType != null)
    {
      final Number n = typeRegistry.convertToNumber(indexType, indexValue);
      if (n.intValue() >= 1)
      {
        indexFrom = n.intValue() - 1;
      }
      else
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 Type lengthType = parameters.getType(1);
      final Object lengthValue = parameters.getValue(1);
      final Number lengthConv = typeRegistry.convertToNumber(lengthType, lengthValue);
      if (lengthConv.doubleValue() < 0)
      {
        throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_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.