Class MessagesHelper


  • public class MessagesHelper
    extends Object
    • Constructor Detail

      • MessagesHelper

        public MessagesHelper()
    • Method Detail

      • format

        public static String format​(Locale locale,
                                    Messages message,
                                    Object... args)
        Interpolate arguments into the message format string for the given message.

        If a non-null locale is provided, an attempt is made to load a properties file for the Message class of which this message is an instance, and the property named by this message's name is used as the format string. If that fails, or if the locale is null, the message object's default format string is used.

        The format string contains embedded place holders indicating where arguments are to be substituted. Each place holder takes the form %n or %{n}, where n is an integer from 1 to the number of arguments. The second form allows interpolation at a site immediately followed by other digits.

        To prevent a percent sign from triggering interpolation, double it: %%. For example, "%%1 %%{2}" will always produce "%1 %{2}".

        The result is obtained by replacing each placeholder with the corresponding argument's Object.toString() value (except that null arguments are rendered as empty strings).

        Parameters:
        message - Messages
        args - Args
        locale - Locale
        Returns:
        message with interpolated arguments