Class MessageFormatSupport

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class MessageFormatSupport
    extends Object
    implements Serializable, Cloneable
    The message format support class helps to translate named references to fields in a message format string into numeric index positions. With the help of this mapping, we can use a standard Java MessageFormat object to reference fields by their name instead of an arbitrary index position.

    A field is referenced by the pattern "$(fieldname)". For additional formatting, all MessageFormat format options are available using the format "$(fieldname, <message option>)". To format a date field with the default short date format, one would use the pattern $(datefield,date,short).

    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Constructor Detail

      • MessageFormatSupport

        public MessageFormatSupport()
        Default Constructor.
    • Method Detail

      • getFormatString

        public String getFormatString()
        Returns the original format string that is used to format the fields. This format string contains named references.
        Returns:
        the format string.
      • setFormatString

        public void setFormatString​(String formatString)
        Updates the named format string and compiles a new field list and message-format string.
        Parameters:
        formatString - the format string.
      • performFormat

        public String performFormat​(DataRow dataRow)
        Formats the message using the fields from the given data-row as values for the parameters.
        Parameters:
        dataRow - the data row.
        Returns:
        the formated message.
      • getCompiledFormat

        public String getCompiledFormat()
        Returns the compiled message format string.
        Returns:
        the compiled message format string.
      • getLocale

        public Locale getLocale()
        Returns the locale that is used to format the messages.
        Returns:
        the locale in the message format.
      • setLocale

        public void setLocale​(Locale locale)
        Updates the locale that is used to format the messages.
        Parameters:
        locale - the locale in the message format.
      • getTimeZone

        public TimeZone getTimeZone()
      • setTimeZone

        public void setTimeZone​(TimeZone timeZone)
      • getNullString

        public String getNullString()
        Returns the replacement text that is used if one of the referenced message parameters is null.
        Returns:
        the replacement text for null-values.
      • setNullString

        public void setNullString​(String nullString)
        Defines the replacement text that is used if one of the referenced message parameters is null.
        Parameters:
        nullString - the replacement text for null-values.
      • getFields

        public String[] getFields()