Class ColumnFormatter


  • public class ColumnFormatter
    extends Object
    Utility for applying Column formatting to column values for display. This utility loads the "Format" property from the given column and builds an appropriate formatter (essentially leveraging the internals of the expression execution engine's support for the "Format()" function). Since formats leverage the expression evaluation engine, the underlying Database's EvalConfig can be used to alter how this utility formats values. Note, formatted values may be suitable for display only (i.e. a formatted value may not be accepted as an input value to a Table add/update method).
    Author:
    James Ahlborn
    Usage:
    General: This class is general use.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String format​(Object val)
      Formats the given value according to the format currently defined for the underlying Column.
      String getFormatString()
      Returns the currently loaded "Format" property for this formatter, may be null.
      String getRowValue​(Object[] rowArray)
      Convenience method for retrieving the appropriate Column value from the given row array and formatting it.
      String getRowValue​(Map<String,​?> rowMap)
      Convenience method for retrieving the appropriate Column value from the given row map and formatting it.
      void reload()
      If the properties for the underlying Column have been modified directly (or the EvalConfig for the underlying Database has been modified), this method may be called to reload the format for the underlying Column.
      void setFormatString​(String fmtStr)
      Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.
    • Method Detail

      • getFormatString

        public String getFormatString()
        Returns the currently loaded "Format" property for this formatter, may be null.
      • setFormatString

        public void setFormatString​(String fmtStr)
                             throws IOException
        Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.
        Parameters:
        fmtStr - the new format string. may be null, in which case the "Format" property is removed from the underlying Column
        Throws:
        IOException
      • format

        public String format​(Object val)
        Formats the given value according to the format currently defined for the underlying Column.
        Parameters:
        val - a valid input value for the DataType of the underlying Column (i.e. a value which could be passed to a Table add/update method for this Column). may be null
        Returns:
        the formatted result, always non-null
      • getRowValue

        public String getRowValue​(Object[] rowArray)
        Convenience method for retrieving the appropriate Column value from the given row array and formatting it.
        Returns:
        the formatted result, always non-null
      • getRowValue

        public String getRowValue​(Map<String,​?> rowMap)
        Convenience method for retrieving the appropriate Column value from the given row map and formatting it.
        Returns:
        the formatted result, always non-null
      • reload

        public final void reload()
                          throws IOException
        If the properties for the underlying Column have been modified directly (or the EvalConfig for the underlying Database has been modified), this method may be called to reload the format for the underlying Column.
        Throws:
        IOException