Examples of MessageFormat


Examples of com.ibm.icu.text.MessageFormat

        //difference between the two param strings are that
        //in the first one, the param position is within the
        //length of the string without param while it is not so
        //in the other case.

        MessageFormat messageFormatter = new MessageFormat("");

        try {
            //Apply pattern with param and print the result
            messageFormatter.applyPattern(pattern[1]);
            Object[] paramArray = {new String("BUG"), new Date()};
            String tempBuffer = messageFormatter.format(paramArray);
            if (!tempBuffer.equals("Message with param:BUG"))
                errln("MessageFormat with one param test failed.");
            logln("Formatted with one extra param : " + tempBuffer);

            //Apply pattern without param and print the result
            messageFormatter.applyPattern(pattern[0]);
            tempBuffer = messageFormatter.format(null);
            if (!tempBuffer.equals("Message without param"))
                errln("MessageFormat with no param test failed.");
            logln("Formatted with no params : " + tempBuffer);

             tempBuffer = messageFormatter.format(paramArray);
             if (!tempBuffer.equals("Message without param"))
                errln("Formatted with arguments > subsitution failed. result = " + tempBuffer.toString());
             logln("Formatted with extra params : " + tempBuffer);
            //This statement gives an exception while formatting...
            //If we use pattern[1] for the message with param,
View Full Code Here

Examples of java.text.MessageFormat

      headerdateformat.setTimeZone(tz);
      rfc850DateFmt.setTimeZone(tz);
      asciiDateFmt.setTimeZone(tz);
      if (serve.isAccessLogged()) {
        // note format string must be not null
        accessFmt = new MessageFormat(
            (String) serve.arguments.get(ARG_ACCESS_LOG_FMT));
        logPlaceholders = new Object[12];
      }
      initSSLAttrs();
      try {
View Full Code Here

Examples of java.text.MessageFormat

    while(keys.hasNext()){
      String header = (String)keys.next();
      String value = getHeader(req,header);
      if(value!=null){
        String pattern = (String)header_map.get(header);
        MessageFormat mf = new MessageFormat(pattern);
        try{
          Object[] vs = mf.parse(value);
          mobile = (String)vs[0];
          if(mobile.startsWith("86"))
            mobile = mobile.substring(2);
          break;
        }catch(Exception e){
View Full Code Here

Examples of java.text.MessageFormat

public class MessageFormatTest extends TestCase
{
  public static void testMessageFormt()
  {
    MessageFormat format = new MessageFormat("{1} {0,number,integer}"); //$NON-NLS-1$
    System.out.println(format.format(new Object[]{new Integer (1), new Integer (1)}));

    Format[] fmt = format.getFormatsByArgumentIndex();

    for (int i = 0; i < fmt.length; i++)
    {
      Format format1 = fmt[i];
      System.out.println(format1);

    }

    format.setFormat(1, null);
    System.out.println(format.format(new Object[]{"-", "a"}));//$NON-NLS-1$ //$NON-NLS-2$
    assertTrue(true);
  }
View Full Code Here

Examples of java.text.MessageFormat

  {
    try
    {
      final String parameter = computeParameter(formulaContext, entries);
      final String pattern = computePattern(configIndicator);
      final MessageFormat messageFormat = new MessageFormat(pattern, formulaContext.getLocalizationContext().getLocale());
      return messageFormat.format(new Object[]{reportPath, parameter});
    }
    catch (UnsupportedEncodingException e)
    {
      throw EvaluationException.getInstance(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
    }
View Full Code Here

Examples of java.text.MessageFormat

  {
    final JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new GridBagLayout());

    pageMessageFormatter = new MessageFormat(messages.getString("progress-dialog.page-label")); //$NON-NLS-1$
    rowsMessageFormatter = new MessageFormat(messages.getString("progress-dialog.rows-label")); //$NON-NLS-1$
    passMessageFormatter = new MessageFormat(messages.getString("progress-dialog.pass-label-0")); //$NON-NLS-1$

    messageCarrier = new JLabel(" "); //$NON-NLS-1$
    passCountMessage = new JLabel(" "); //$NON-NLS-1$
    rowCountMessage = new JLabel(" "); //$NON-NLS-1$
    pageCountMessage = new JLabel(" "); //$NON-NLS-1$
View Full Code Here

Examples of java.text.MessageFormat

  /**
   * Creates a new ConfigEditorPanel.
   */
  public ConfigEditorPanel()
  {
    moduleNameFormat = new MessageFormat("{0} - Version {1}.{2}-{3}"); //$NON-NLS-1$

    moduleNameField = new JTextArea();
    moduleNameField.setName("ModuleNameField"); //$NON-NLS-1$
    moduleNameField.setMinimumSize(new Dimension(100, 10));
    moduleNameField.setEditable(false);
View Full Code Here

Examples of java.text.MessageFormat

     * @param pattern the message pattern
     * @param arguments the message arguments
     * @return the formatted string
     */
    public String message(String pattern, Object[] arguments) {
        MessageFormat format = new MessageFormat(pattern, getLocale());
        return format.format(arguments, new StringBuffer(), null).toString();
    }
View Full Code Here

Examples of java.text.MessageFormat

    //             so the "{0}" in "AB '{0}' CD" will not be replaced.
    //             In order to avoid this we quote every ' with '', so
    //             everthing will be replaced as expected.
    msg = RegainToolkit.replace(msg, "'", "''");
   
    MessageFormat format = new MessageFormat(msg, mBundle.getLocale());
    return format.format(args);   
  }
View Full Code Here

Examples of java.text.MessageFormat

      }
      else {
         args[0] = dat;
         StringBuffer text = new StringBuffer();
         if (formatter == null) {
            formatter = new MessageFormat(format);
         }
         formatter.format(args, text, null);
         sb.append(text);
      }
      sb.append(" ");
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.