Package org.pentaho.reporting.engine.classic.core.function

Examples of org.pentaho.reporting.engine.classic.core.function.Expression


  {
    final ExpressionCollection expressionCollection = report.getExpressions();
    final Expression[] expressions = expressionCollection.getExpressions();
    for (int j = 1; j < expressions.length; j++)
    {
      final Expression expression = expressions[j];
      if (element == expression)
      {
        expressionCollection.removeExpression(j);
        expressionCollection.add(j - 1, expression);
View Full Code Here


      final StyleKey styleKey = keys[i];
      if (styleKey == null)
      {
        continue;
      }
      final Expression styleExpression = visualElement.getStyleExpression(styleKey);
      if (styleExpression != null)
      {
        retval[styleKey.identifier] = styleExpression;
      }
    }
View Full Code Here

      final Iterator iterator = resultExpressions.entrySet().iterator();
      while (iterator.hasNext())
      {
        final Map.Entry entry = (Map.Entry) iterator.next();
        final StyleKey key = (StyleKey) entry.getKey();
        final Expression value = (Expression) entry.getValue();

        for (int j = 0; j < visualElements.length; j++)
        {
          final Element element = visualElements[j];
          if (ObjectUtilities.equal(value, element.getStyleExpression(key)) == false)
          {
            if (value != null)
            {
              element.setStyleExpression(key, value.getInstance());
            }
            else
            {
              element.setStyleExpression(key, null);
            }
View Full Code Here

  {
    final ExpressionCollection expressionCollection = report.getExpressions();
    final Expression[] expressions = expressionCollection.getExpressions();
    for (int j = 1; j < expressions.length; j++)
    {
      final Expression expression = expressions[j];
      if (element == expression)
      {
        expressionCollection.removeExpression(j);
        expressionCollection.add(0, expression);
View Full Code Here

      }
      else
      {
        editorDialog = new ExpressionEditorDialog();
      }
      final Expression expression = editorDialog.performEditExpression
          (reportDesignerContext, value);
      if (editorDialog.isConfirmed() == false)
      {
        cancelCellEditing();
        return;
View Full Code Here

  public void writeExpressions(final ExpressionCollection exp)
      throws IOException
  {
    for (int i = 0; i < exp.size(); i++)
    {
      final Expression expression = exp.getExpression(i);
      writeExpression(expression);
    }
  }
View Full Code Here

    {
      final FunctionsWriter fnWriter = new FunctionsWriter(getReportWriter(), writer);
      for (final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet())
      {
        final StyleKey key = entry.getKey();
        final Expression ex = entry.getValue();
        fnWriter.writeStyleExpression(ex, key);
      }
    }
  }
View Full Code Here

    boolean retval = false;
    final ElementStyleSheet style = e.getStyle();
    for (final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet())
    {
      final StyleKey key = entry.getKey();
      final Expression ex = entry.getValue();
      if (ex == null)
      {
        continue;
      }
      retval = true;
      ex.setRuntime(getRuntime());
      try
      {
        final Object value = evaluate(ex);
        if (value == null)
        {
          style.setStyleProperty(key, null);
        }
        else if (key.getValueType().isInstance(value))
        {
          style.setStyleProperty(key, value);
        }
        else if (value instanceof ErrorValue)
        {
          if (failOnErrors)
          {
            throw new InvalidReportStateException(String.format
                ("Failed to evaluate style-expression for key %s on element [%s]",// NON-NLS
                    key.getName(),
                    FunctionUtilities.computeElementLocation(e)));
          }
          style.setStyleProperty(key, null);
        }
        else
        {
          final ValueConverter valueConverter = ConverterRegistry.getInstance().getValueConverter(key.getValueType());
          if (valueConverter != null)
          {
            // try to convert it ..
            final Object o = ConverterRegistry.toPropertyValue(String.valueOf(value), key.getValueType());
            style.setStyleProperty(key, o);
          }
          else
          {
            style.setStyleProperty(key, null);
          }
        }
      }
      catch (InvalidReportStateException exception)
      {
        throw exception;
      }
      catch (Exception exception)
      {
        if (logger.isDebugEnabled())
        {
          logger.debug(String.format
              ("Failed to evaluate style expression for element '%s', style-key %s", // NON-NLS
                  e, key), exception);
        }
        if (failOnErrors)
        {
          throw new InvalidReportStateException(String.format
              ("Failed to evaluate style-expression for key %s on element [%s]",// NON-NLS
                  key.getName(),
                  FunctionUtilities.computeElementLocation(e)), exception);
        }
        // ignored, but we clear the style as we have no valid value anymore.
        style.setStyleProperty(key, null);
      }
      finally
      {
        ex.setRuntime(null);
      }
    }
    return retval;
  }
View Full Code Here

      final String namespace = namespaces[namespaceIdx];
      final String[] names = e.getAttributeExpressionNames(namespace);
      for (int nameIdx = 0; nameIdx < names.length; nameIdx++)
      {
        final String name = names[nameIdx];
        final Expression ex = e.getAttributeExpression(namespace, name);
        if (ex == null)
        {
          continue;
        }

        final AttributeMetaData attribute = metaData.getAttributeDescription(namespace, name);
        if (attribute != null && attribute.isDesignTimeValue())
        {
          continue;
        }

        retval = true;
        ex.setRuntime(getRuntime());
        try
        {
          final Object value = evaluate(ex);
          if (attribute == null)
          {
            // Not a declared attribute, but maybe one of the output-handlers can work on this one.
            e.setAttribute(namespace, name, value);
          }
          else
          {
            final Class<?> type = attribute.getTargetType();
            if (value == null || type.isAssignableFrom(value.getClass()))
            {
              e.setAttribute(namespace, name, value);
            }
            else if (value instanceof ErrorValue)
            {
              if (failOnErrors)
              {
                throw new InvalidReportStateException(String.format
                    ("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
                        namespace, name,
                        FunctionUtilities.computeElementLocation(e)));
              }
              e.setAttribute(namespace, name, null);
            }
            else
            {

              final PropertyEditor propertyEditor = attribute.getEditor();
              if (propertyEditor != null)
              {
                propertyEditor.setAsText(String.valueOf(value));
                e.setAttribute(namespace, name, propertyEditor.getValue());
              }
              else
              {
                final ValueConverter valueConverter = instance.getValueConverter(type);
                if (type.isAssignableFrom(String.class))
                {
                  // the attribute would allow raw-string values, so copy the element ..
                  e.setAttribute(namespace, name, value);
                }
                else if (valueConverter != null)
                {
                  final Object o = ConverterRegistry.toPropertyValue(String.valueOf(value), type);
                  e.setAttribute(namespace, name, o);
                }
                else
                {
                  // undo any previous computation
                  e.setAttribute(namespace, name, null);
                }
              }
            }
          }
        }
        catch (InvalidReportStateException exception)
        {
          throw exception;
        }
        catch (Exception exception)
        {
          if (logger.isDebugEnabled())
          {
            logger.debug(String.format
                ("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
                    namespace, name,
                    FunctionUtilities.computeElementLocation(e)), exception);
          }
          if (failOnErrors)
          {
            throw new InvalidReportStateException(String.format
                ("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
                    namespace, name,
                    FunctionUtilities.computeElementLocation(e)), exception);
          }
          e.setAttribute(namespace, name, null);
        }
        finally
        {
          ex.setRuntime(null);
        }
      }
    }
    return retval;
  }
View Full Code Here

  protected void doneParsing() throws SAXException {
    for (int i = 0; i < styleExpressions.size(); i++) {
      final StyleExpressionHandler handler = styleExpressions.get(i);
      final StyleKey key = handler.getKey();
      if (handler.getKey() != null) {
        final Expression expression = handler.getExpression();
        element.setStyleExpression(key, expression);
      }
    }

    for (int i = 0; i < attributeExpressions.size(); i++) {
      final AttributeExpressionReadHandler handler = attributeExpressions.get(i);
      final Expression expression = handler.getExpression();
      element.setAttributeExpression(handler.getNamespace(), handler.getName(), expression);
    }

    for (int i = 0; i < bulkattributes.size(); i++) {
      final BulkAttributeReadHandler attributeReadHandler = bulkattributes.get(i);
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.function.Expression

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.