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

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


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

      while (sequence.hasNext())
      {
        final LValue lValue = sequence.nextRawValue();
        final TypeValuePair pair = lValue.evaluate();
        final Type type1 = pair.getType();
        final Object o = pair.getValue();
        final String str = typeRegistry.convertToText(type1, o);
        computedResult.append(str);
View Full Code Here


    }

    for (int paramIdx = 0; paramIdx < parameterCount; paramIdx++)
    {
      final Object value = parameters.getValue(paramIdx);
      final Sequence sequence = new RecursiveSequence(value, context);

      while (sequence.hasNext())
      {
        final Object o = sequence.next();
        computedResult.add(o);
      }
    }

    return new TypeValuePair(AnyType.ANY_ARRAY, computedResult.toArray());
View Full Code Here

    final Type startType = parameters.getType(1);
    final Object startValue = parameters.getValue(1);
    final Type lengthType = parameters.getType(2);
    final Object lengthValue = parameters.getValue(2);

    final Sequence text = new RecursiveSequence(textValue, context);
    final Number start = typeRegistry.convertToNumber(startType, startValue);
    final Number length = typeRegistry.convertToNumber(lengthType, lengthValue);

    if (length.doubleValue() < 0 || start.doubleValue() < 1)
    {
View Full Code Here

    {
      try
      {
        final Type type = parameters.getType(paramIdx);
        final Object value = parameters.getValue(paramIdx);
        final Sequence sequence = context.getTypeRegistry().convertToNumberSequence(type, value, true);

        while (sequence.hasNext())
        {
          sequence.next();
          count++;
        }
      }
      catch (EvaluationException e)
      {
View Full Code Here

    for (int paramIdx = 1; paramIdx < parameterCount; paramIdx++)
    {
      try
      {
        final Object value = parameters.getValue(paramIdx);
        final Sequence sequence = new RecursiveSequence(value, context);

        while (sequence.hasNext())
        {
          final Object o = sequence.next();
          needles.add(new TypeValuePair(AnyType.TYPE, o));
        }
      }
      catch (EvaluationException e)
      {
        if (e.getErrorValue() == LibFormulaErrorValue.ERROR_NA_VALUE)
        {
          needles.add(new TypeValuePair(AnyType.TYPE, null));
        }
        else
        {
          throw e;
        }
      }
    }

    if (needles.size() == 0)
    {
      return new TypeValuePair(LogicalType.TYPE, Boolean.TRUE);
    }


    final Object value = parameters.getValue(0);
    final Sequence sequence = new RecursiveSequence(value, context);
    final EqualOperator equalOperator = new EqualOperator();

    while (sequence.hasNext())
    {
      final Object o = sequence.next();
      final TypeValuePair sequenceValue = new TypeValuePair(AnyType.TYPE, o);
      for (int i = needles.size() - 1; i >= 0; i -= 1)
      {
        final TypeValuePair needle = needles.get(i);
        if (needle.getValue() == o)
View Full Code Here

      stack.push(s);
      return hasNext();
    }
    else if (o instanceof Sequence)
    {
      final Sequence s = (Sequence) o;
      if (s.hasNext())
      {
        final Object object = s.next();
        stack.push(s);
        stack.push(object);
      }
      return hasNext();
    }
View Full Code Here

  public Object next() throws EvaluationException
  {
    final Object o = stack.pop();
    if (o instanceof Sequence)
    {
      final Sequence sequence = (Sequence) o;
      return sequence.next();
    }
    return (o);
  }
View Full Code Here

    }
    final TypeRegistry typeRegistry = context.getTypeRegistry();

    final Object textValue = parameters.getValue(0);

    final Sequence text = new RecursiveSequence(textValue, context);
    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);
      }

      length = lengthConv.intValue();
    }
    else
    {
      length = 1;
    }

    final ArrayList retval = new ArrayList(length);
    if (length > 0)
    {
      while (text.hasNext())
      {
        final Object o = text.next();
        retval.add(o);
        if (retval.size() == length)
        {
          break;
        }
View Full Code Here

    {
      if (value != null)
      {
        try
        {
          final Sequence sequence = context.getTypeRegistry().convertToSequence(type, value);

          while (sequence.hasNext())
          {
            final Object o = sequence.next();
            if (o == null)
            {
              count++;
            }
          }
View Full Code Here

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

    final Sequence sequence =
        context.getTypeRegistry().convertToSequence(parameters.getType(0), parameters.getValue(0));
    if (sequence == null)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_NA_VALUE);
    }

    String quote = "\"";
    String separator = ",";
    boolean doQuoting = false;
    if (parameterCount > 1)
    {
      final Type indexType = parameters.getType(1);
      final Object indexValue = parameters.getValue(1);
      final Boolean indexNumber = context.getTypeRegistry().convertToLogical(indexType, indexValue);
      doQuoting = Boolean.TRUE.equals(indexNumber);
    }

    if (parameterCount > 2)
    {
      final Type indexType = parameters.getType(2);
      final Object indexValue = parameters.getValue(2);
      separator = context.getTypeRegistry().convertToText(indexType, indexValue);
    }

    if (parameterCount > 3)
    {
      final Type indexType = parameters.getType(3);
      final Object indexValue = parameters.getValue(3);
      quote = context.getTypeRegistry().convertToText(indexType, indexValue);
    }

    if (doQuoting == false)
    {
      StringBuilder b = new StringBuilder();
      while (sequence.hasNext())
      {
        final Object o = sequence.next();
        if (o != null)
        {
          b.append(o);
        }
        if (sequence.hasNext())
        {
          b.append(separator);
        }
      }
      return new TypeValuePair(TextType.TYPE, b.toString());
    }
    else
    {
      final CSVQuoter quoter = new CSVQuoter(quote.charAt(0), quote.charAt(0), true);
      StringBuilder b = new StringBuilder();
      while (sequence.hasNext())
      {
        final Object o = sequence.next();
        if (o != null)
        {
          b.append(quoter.doQuoting(String.valueOf(o)));
        }
        if (sequence.hasNext())
        {
          b.append(separator);
        }
      }
      return new TypeValuePair(TextType.TYPE, b.toString());
View Full Code Here

TOP

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

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.