Class MessagesHelper
- java.lang.Object
-
- com.networknt.oas.validator.msg.MessagesHelper
-
public class MessagesHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description MessagesHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringformat(Locale locale, Messages message, Object... args)Interpolate arguments into the message format string for the given message.static PropertiesloadLocalizations(Class<? extends Messages> msgClass, Locale locale)
-
-
-
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
%nor%{n}, wherenis 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- Messagesargs- Argslocale- Locale- Returns:
- message with interpolated arguments
-
loadLocalizations
public static Properties loadLocalizations(Class<? extends Messages> msgClass, Locale locale)
-
-