Class TableFormatter


public class TableFormatter extends Formatter<TableFormatContext>
TableFormatter formats a table as a String, using the settings of the TableFormatContext. The TableFormatContext is filled by setting properties of the TableFormatContext. Note that there is no guarantee that the format can always be honored. As an example, when the required width is too small to fit the answer, the output will show the correct result, but violate the width setting.

Copyright (c) 2026-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.

Author:
Alexander Verbraeck
  • Constructor Details

  • Method Details

    • table

      QuantityTable<?> table()
      Return the value as a table (or table).
      Returns:
      the value as a table (or table)
    • format

      public static String format(QuantityTable<?> table, TableFormat tableFormat)
      Format a table according to a number of table format settings. Note that this method might not be thread-safe for setting the default Locale. If another thread changes the Locale while formatting, outcomes could vary.
      Parameters:
      table - the table to format
      tableFormat - the format to apply to the table
      Returns:
      a String with a formatted table, matching the table format settings as closely as possible
    • format

      public static String format(AbsQuantityTable<?,?> absTable, TableFormat tableFormat)
      Format an absolute table according to a number of table format settings. Note that this method might not be thread-safe for setting the default Locale. If another thread changes the Locale while formatting, outcomes could vary.
      Parameters:
      absTable - the absolute table to format
      tableFormat - the format to apply to the table
      Returns:
      a String with a formatted table, matching the table format settings as closely as possible
    • format

      String format()
      Return the table, formatted according to the context settings.
      Specified by:
      format in class Formatter<TableFormatContext>
      Returns:
      the formatted table