- java.lang.Object
-
- com.aoapps.lang.text.MessageFormatFactory
-
public final class MessageFormatFactory extends Object
Creates MessageFormat objects and caches them. This may be used as an alternative to the MessageFormat constructor to increase performance.The following are the results of a single-threaded benchmark with a simple two-value substitution:
Comparing constructor/factory and format together: Constructor: 1148.127153 Factory....: 283.366235 4 times improvement Comparing constructor/factory only: Constructor: 985.182660 Factory....: 42.602040 23 times improvementLonger or more complicated patterns should benefit even more (this assertion not tested).
- Author:
- AO Industries, Inc.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static UnmodifiableMessageFormatgetMessageFormat(String pattern)Gets a message format for the provided format in the current thread locale.static UnmodifiableMessageFormatgetMessageFormat(String pattern, Locale locale)Gets a message format for the provided format and locale.
-
-
-
Method Detail
-
getMessageFormat
public static UnmodifiableMessageFormat getMessageFormat(String pattern)
Gets a message format for the provided format in the current thread locale.- Returns:
- a MessageFormat that may not be modified with any of its setters or other mutator methods.
- See Also:
ThreadLocale
-
getMessageFormat
public static UnmodifiableMessageFormat getMessageFormat(String pattern, Locale locale)
Gets a message format for the provided format and locale.- Returns:
- a MessageFormat that may not be modified with any of its setters or other mutator methods.
-
-