Package org.apache.sis.internal.util
Class AutoMessageFormat
java.lang.Object
java.text.Format
java.text.MessageFormat
org.apache.sis.internal.util.AutoMessageFormat
- All Implemented Interfaces:
Serializable
,Cloneable
A message format which adjust automatically the number of fraction digits needed for formatting numbers.
Callers need to invoke
configure(Object[])
before to invoke any format(…)
method.- Since:
- 1.0
- Version:
- 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.MessageFormat
MessageFormat.Field
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NumberFormat[]
Formats that may need to be configured before to write a value, ornull
if none.private boolean
Whether theformatsToConfigure
needs to be updated. -
Constructor Summary
ConstructorsConstructorDescriptionAutoMessageFormat
(String pattern) Creates a new message for the default locale.AutoMessageFormat
(String pattern, Locale locale) Creates a new message for the given locale. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPattern
(String pattern) Modifies the pattern used by this message format.void
Configures the number of fraction digits in the formats used by thisMessageFormat
.Methods inherited from class java.text.MessageFormat
clone, equals, format, 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 Details
-
formatsToConfigure
Formats that may need to be configured before to write a value, ornull
if none. May contain null elements. This information is used for adjusting the amount of fraction digits. -
update
private transient boolean updateWhether theformatsToConfigure
needs to be updated.
-
-
Constructor Details
-
AutoMessageFormat
Creates a new message for the default locale.- Parameters:
pattern
- the pattern for this message format.
-
AutoMessageFormat
Creates a new message for the given locale.- Parameters:
pattern
- the pattern for this message format.locale
- the locale for this message format.
-
-
Method Details
-
applyPattern
Modifies the pattern used by this message format.- Overrides:
applyPattern
in classMessageFormat
- Parameters:
pattern
- the new pattern for this message format
-
configure
Configures the number of fraction digits in the formats used by thisMessageFormat
. This method can work only for parameters declared as"{#,number}"
in the message pattern.- Parameters:
arguments
- the argument to be given toFormat.format(Object)
.
-