Package java.text

Examples of java.text.MessageFormat.format()


                    request.setAttribute(REQUIRED,Boolean.TRUE);
                }
                else
                {
                    MessageFormat mf = new MessageFormat(bundle.getString("chgpwd.message.expires.in.days"));
                    request.setAttribute(WHY,mf.format(new Integer[]{passwordDaysValid}));
                }
            }
           
            ArrayList errorMessages = (ArrayList)request.getPortletSession().getAttribute(ERROR_MESSAGES);
            if (errorMessages != null )
View Full Code Here


  if (descriptor == null) {
      Object[] msgArg0 = {new String(protocolName)};
      MessageFormat formatter = new MessageFormat("");
      formatter.setLocale(Locale.getDefault());
      formatter.applyPattern(JaiI18N.getString("RemoteJAI16"));
      throw new RuntimeException(formatter.format(msgArg0));
  }

  int count=0;
  int numRetries = getNumRetries();
  int retryInterval = getRetryInterval();
View Full Code Here

  if (descriptor == null) {
      Object[] msgArg0 = {new String(protocolName)};
      MessageFormat formatter = new MessageFormat("");
      formatter.setLocale(Locale.getDefault());
      formatter.applyPattern(JaiI18N.getString("RemoteJAI16"));
      throw new ImagingException(formatter.format(msgArg0));
  }

  int count=0;
  int numRetries = getNumRetries();
  int retryInterval = getRetryInterval();
View Full Code Here

     */
    private String formatMsg(String key, Object[] args) {
        MessageFormat mf = new MessageFormat(key);
        mf.setLocale(Locale.getDefault());

        return mf.format(args);
    }
}
View Full Code Here

        if (args != null)
        {
            // apply the arguments
            final MessageFormat format = new MessageFormat(message, getLocale());
            message = format.format(args);
        }

        return message;
    }
View Full Code Here

    static String formatMessage(String msg, Locale locale, Object... messageParams) {
        if (msg.contains("{")) {
            try {
                MessageFormat messageFormat = new MessageFormat(msg, locale);
                msg = messageFormat.format(messageParams);
            } catch (IllegalArgumentException e) {
                // Do nothing, use original string unchanged.
            }
        }
        return msg;
View Full Code Here

          value = Strings.replaceAll(value, "${", "$'{'").toString();
        }

        // Apply the parameters
        final MessageFormat format = new MessageFormat(value, getLocale());
        value = format.format(realParams);

        if (model != null)
        {
          // un escape the substitute properties
          value = Strings.replaceAll(value, "$'{'", "${").toString();
View Full Code Here

    MessageFormat format = new MessageFormat(
      "Weather station \"Europe''s main weather station\" reports that the temperature is {0} {1}",
      tester.getSession().getLocale());

    ws.setCurrentTemperature(25.7);
    String expected = format.format(new Object[] { 25.7, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());

    ws.setCurrentTemperature(11.5);
    expected = format.format(new Object[] { 11.5, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());
View Full Code Here

    ws.setCurrentTemperature(25.7);
    String expected = format.format(new Object[] { 25.7, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());

    ws.setCurrentTemperature(11.5);
    expected = format.format(new Object[] { 11.5, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());
  }

  /** */
  @Test
 
View Full Code Here

      "The report for {0,date,medium}, shows the temperature as {2,number,###.##} {3} and the weather to be {1}",
      page.getLocale());
    StringResourceModel model = new StringResourceModel("weather.detail", page, wsModel,
      cal.getTime(), "${currentStatus}", new PropertyModel<Double>(wsModel,
        "currentTemperature"), new PropertyModel<String>(wsModel, "units"));
    String expected = format.format(new Object[] { cal.getTime(), "sunny", 25.7, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());
    ws.setCurrentStatus("raining");
    ws.setCurrentTemperature(11.568);
    expected = format.format(new Object[] { cal.getTime(), "raining", 11.568, "\u00B0C" });
    assertEquals("Text should be as expected", expected, model.getString());
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.