Package java.text

Examples of java.text.MessageFormat.format()


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++)
    {
View Full Code Here


      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

    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

     * @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();
    }

    /**
     * Return a formatted string using the given message pattern and arguments.
     * See {@link java.text.MessageFormat} for information on the message
View Full Code Here

    //             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);   
  }


  /**
   * Gets a localized message.
View Full Code Here

            resourceString = bundle.getString(key);
            if (arguments != null)
            {
                final MessageFormat format = new MessageFormat(resourceString,
                        context.getViewRoot().getLocale());
                resourceString = format.format(arguments);
            }
        }
        catch (final MissingResourceException exception)
        {
            resourceString = key;
View Full Code Here

        contentLen += cmdsize;
      }
     

      MessageFormat mFormat = new MessageFormat(sb.toString());
      String headstr = mFormat.format(new Object[] { 200, "OK", contentLen});

     
      byte[] headdata = null;
      try {
        headdata = headstr.getBytes("ISO-8859-1");
View Full Code Here

        System.arraycopy(stringList, 0, args, 1, stringList.length);
        args[0] = new Integer(stringList.length);

        // Format it using the pattern in the resource
        MessageFormat format = new MessageFormat(listPattern);
        return format.format(args);
    }

    /**
     * Given a list of strings, return a list shortened to three elements.
     * Shorten it by applying the given format to the first two elements
View Full Code Here

    }
    if (null == text && defaultVal != null) {
      MessageFormat format = new MessageFormat(defaultVal);
      format.setLocale(getLocale());
      format.applyPattern(defaultVal);
      return format.format(args);
    }
    return text;
  }

}
View Full Code Here

  public String getText(String key, Object[] args) {
    String text = bundle.getString(key);
    MessageFormat format = new MessageFormat(text);
    format.setLocale(locale);
    format.applyPattern(text);
    return format.format(args);
  }

  public void setLocale(Locale locale) {
    this.locale = locale;
  }
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.