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

Examples of org.pentaho.reporting.engine.classic.core.filter.MessageFormatSupport


            //noinspection SimpleDateFormatWithoutLocale
            final DateFormat fmt = new SimpleDateFormat(String.valueOf(o));
          }
          else if ("Message".equals(role))//NON-NLS
          {
            final MessageFormatSupport support = new MessageFormatSupport();
            support.setFormatString(fmtString);
          }
        }
        catch (Exception e)
        {
          final StyleMetaData attrMetaData = element.getMetaData().getStyleDescription(styleKey);
View Full Code Here


            //noinspection SimpleDateFormatWithoutLocale
            final DateFormat fmt = new SimpleDateFormat(String.valueOf(o));
          }
          else if ("Message".equals(role))//NON-NLS
          {
            final MessageFormatSupport support = new MessageFormatSupport();
            support.setFormatString(fmtString);
          }
        }
        catch (Exception e)
        {
          resultHandler.notifyInspectionResult(new InspectionResult(this, InspectionResult.Severity.WARNING,
View Full Code Here

        final String message = (String) oldAttributes.getAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE);
        visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, null);
        try
        {

          final MessageFormatSupport fmt = new MessageFormatSupport();
          fmt.setFormatString(message);
          final String rawFormat = fmt.getCompiledFormat();
          final MessageFormat msg = new MessageFormat(rawFormat);
          final Format[] subFormats = msg.getFormats();

          if (targetElementType instanceof DateFieldType)
          {
            final int sdf = findFirstDateFormat(subFormats);
            if (sdf != -1)
            {
              final SimpleDateFormat df = (SimpleDateFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else if (targetElementType instanceof NumberFieldType)
          {
            final int sdf = findFirstNumberFormat(subFormats);
            if (sdf != -1)
            {
              final DecimalFormat df = (DecimalFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else
          {
            final String[] fields = fmt.getFields();
            if (fields.length > 0)
            {
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[0]);
            }
            else
View Full Code Here

  /**
   * Default constructor.
   */
  public MessageFormatExpression()
  {
    messageFormatSupport = new MessageFormatSupport();
    encoding = "UTF-8";
  }
View Full Code Here


  public Expression getInstance()
  {
    final MessageFormatExpression ex = (MessageFormatExpression) super.getInstance();
    ex.messageFormatSupport = new MessageFormatSupport();
    return ex;
  }
View Full Code Here

  /**
   * Default constructor.
   */
  public ResourceMesssageFormatExpression()
  {
    messageFormatSupport = new MessageFormatSupport();
  }
View Full Code Here

    {
      return nullValue;
    }
   
    final MessageTypeContext context = element.getElementContext(MessageTypeContext.class);
    final MessageFormatSupport messageFormatFilter = context.messageFormatFilter;
    messageFormatFilter.setFormatString(String.valueOf(message));

    final Object messageNullValue = element.getAttribute
        (AttributeNames.Core.NAMESPACE, AttributeNames.Core.MESSAGE_NULL_VALUE);
    if (messageNullValue != null)
    {
      messageFormatFilter.setNullString(String.valueOf(messageNullValue));
    }
    else if (nullValue != null)
    {
      messageFormatFilter.setNullString(String.valueOf(nullValue));
    }
    else
    {
      messageFormatFilter.setNullString(null);
    }

    final ResourceBundleFactory resourceBundleFactory = runtime.getResourceBundleFactory();
    final Locale newLocale = resourceBundleFactory.getLocale();
    if (ObjectUtilities.equal(newLocale, messageFormatFilter.getLocale()) == false)
    {
      messageFormatFilter.setLocale(newLocale);
    }
   
    final TimeZone newTimeZone = resourceBundleFactory.getTimeZone();
    if (ObjectUtilities.equal(newTimeZone, messageFormatFilter.getTimeZone()) == false)
    {
      messageFormatFilter.setTimeZone(newTimeZone);
    }

    final Object value = messageFormatFilter.performFormat(runtime.getDataRow());
    if (value == null)
    {
      return nullValue;
    }
    return String.valueOf(value);
View Full Code Here

  public static class MessageTypeContext
  {
    public MessageTypeContext()
    {
      messageFormatFilter = new MessageFormatSupport();
    }
View Full Code Here

    return template;
  }

  public FormattedDataBuilder createDataBuilder()
  {
    MessageFormatSupport messageFormatSupport = new MessageFormatSupport();
    messageFormatSupport.setLocale(Locale.ENGLISH);
    messageFormatSupport.setFormatString(getTemplate());
    messageFormatSupport.setNullString("");
    return new CsvFormattedDataBuilder(idMapping, messageFormatSupport, getQuoter(), encoding);
  }
View Full Code Here

      return new String[]{String.valueOf(attributeValue)};
    }
    else if ("Message".equals(propertyRole))
    {
      final String message = String.valueOf(attributeValue);
      final MessageFormatSupport messageFormatSupport = new MessageFormatSupport();
      messageFormatSupport.setFormatString(message);
      return messageFormatSupport.getFields();
    }
    else if ("Formula".equals(propertyRole))
    {
      final String formula = String.valueOf(attributeValue);
      try
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.filter.MessageFormatSupport

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.