Class LocaleMessageFormat

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class LocaleMessageFormat
    extends MessageFormat
    LocaleMessageFormat provides a means to produce concatenated messages in a language-neutral way in the Locale utility class.

    LocaleMessageFormat takes a set of objects, formats them, then inserts the formatted strings into the pattern at the appropriate places.

    In addition to the standard JDK MessageFormat, LocaleMessageFormat provides the FormatStyle named "raw". This new style does not try to format the given data according to the locale. It simply put the not-formatted data in the result.

    Since:
    6.4
    Version:
    17.0 2020-01-04 14:41:35
    Author:
    Stéphane GALLAND
    See Also:
    Serialized Form
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    vmutils
    • Field Detail

      • RAW_FORMAT_STYLE

        public static final String RAW_FORMAT_STYLE
        String that corresponds to the raw format style.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LocaleMessageFormat

        public LocaleMessageFormat​(String pattern)
        Construct a message format with the given pattern.
        Parameters:
        pattern - the pattern for this message format
        Throws:
        IllegalArgumentException - if the pattern is invalid
      • LocaleMessageFormat

        public LocaleMessageFormat​(String pattern,
                                   Locale locale)
        Construct a message format with the given pattern and locale.
        Parameters:
        pattern - the pattern for this message format
        locale - the locale for this message format
        Throws:
        IllegalArgumentException - if the pattern is invalid
    • Method Detail

      • format

        @Pure
        public static String format​(String pattern,
                                    Object... arguments)
        Creates a LocaleMessageFormat with the given pattern and uses it to format the given arguments. This is equivalent to
        (new MessageFormat(pattern)).format(arguments, new StringBuffer(), null).toString()
        Parameters:
        pattern - the pattern of string.
        arguments - the dynamic arguments to put inside the string.
        Returns:
        the formatted string.
        Throws:
        IllegalArgumentException - if the pattern is invalid, or if an argument in the arguments array is not of the type expected by the format element(s) that use it.