Class AutoMessageFormat

java.lang.Object
java.text.Format
java.text.MessageFormat
org.apache.sis.internal.util.AutoMessageFormat
All Implemented Interfaces:
Serializable, Cloneable

public final class AutoMessageFormat extends MessageFormat
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:
  • Field Details

    • formatsToConfigure

      private transient NumberFormat[] formatsToConfigure
      Formats that may need to be configured before to write a value, or null if none. May contain null elements. This information is used for adjusting the amount of fraction digits.
    • update

      private transient boolean update
      Whether the formatsToConfigure needs to be updated.
  • Constructor Details

    • AutoMessageFormat

      public AutoMessageFormat(String pattern)
      Creates a new message for the default locale.
      Parameters:
      pattern - the pattern for this message format.
    • AutoMessageFormat

      public AutoMessageFormat(String pattern, Locale locale)
      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

      public void applyPattern(String pattern)
      Modifies the pattern used by this message format.
      Overrides:
      applyPattern in class MessageFormat
      Parameters:
      pattern - the new pattern for this message format
    • configure

      public void configure(Object[] arguments)
      Configures the number of fraction digits in the formats used by this MessageFormat. This method can work only for parameters declared as "{#,number}" in the message pattern.
      Parameters:
      arguments - the argument to be given to Format.format(Object).