- java.lang.Object
-
- java.text.Format
-
- java.text.MessageFormat
-
- org.arakhne.afc.vmutil.locale.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 theLocale
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 theFormatStyle
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.MessageFormat
MessageFormat.Field
-
-
Field Summary
Fields Modifier and Type Field Description static String
RAW_FORMAT_STYLE
String that corresponds to the raw format style.
-
Constructor Summary
Constructors Constructor Description LocaleMessageFormat(String pattern)
Construct a message format with the given pattern.LocaleMessageFormat(String pattern, Locale locale)
Construct a message format with the given pattern and locale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyPattern(String pattern)
static String
format(String pattern, Object... arguments)
Creates a LocaleMessageFormat with the given pattern and uses it to format the given arguments.-
Methods inherited from class java.text.MessageFormat
clone, equals, format, format, formatToCharacterIterator, getFormats, getFormatsByArgumentIndex, getLocale, hashCode, parse, parse, parseObject, setFormat, setFormatByArgumentIndex, setFormats, setFormatsByArgumentIndex, setLocale, toPattern
-
Methods inherited from class java.text.Format
format, parseObject
-
-
-
-
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 formatlocale
- 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 thearguments
array is not of the type expected by the format element(s) that use it.
-
applyPattern
public void applyPattern(String pattern)
- Overrides:
applyPattern
in classMessageFormat
-
-