Package org.djunits.formatter
Class TableFormatter
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
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Stringformat()Return the table, formatted according to the context settings.static Stringformat(AbsQuantityTable<?, ?> absTable, TableFormat tableFormat) Format an absolute table according to a number of table format settings.static Stringformat(QuantityTable<?> table, TableFormat tableFormat) Format a table according to a number of table format settings.(package private) QuantityTable<?>table()Return the value as a table (or table).Methods inherited from class org.djunits.formatter.Formatter
checkDisplayUnit, checkSiUnits, checkUnitString, formatEngineering, formatFixedEngFallback, formatFixedFloat, formatFixedSciFallback, formatReference, formatScientific, formatUnit, formatValue, formatVariableLength, pad, restoreLocale, saveLocale
-
Constructor Details
-
TableFormatter
TableFormatter(QuantityTable<?> table, TableFormatContext ctx) - Parameters:
table- the table to formatctx- the format context
-
-
Method Details
-
table
QuantityTable<?> table()Return the value as a table (or table).- Returns:
- the value as a table (or table)
-
format
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 formattableFormat- the format to apply to the table- Returns:
- a String with a formatted table, matching the table format settings as closely as possible
-
format
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 formattableFormat- 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:
formatin classFormatter<TableFormatContext>- Returns:
- the formatted table
-