Package org.djunits.formatter
Class VectorFormatter
VectorFormatter formats a vector as a String, using the settings of the
VectorFormatContext. The
VectorFormatContext is filled by setting flags using the VectorFormat. 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 vector, formatted according to the context settings.static Stringformat(AbsVector<?, ?, ?, ?, ?> absVector, VectorFormat<?> vectorFormat) Format an absolute vector according to a number of vector format settings.static Stringformat(Vector<?, ?, ?, ?, ?> vector, VectorFormat<?> vectorFormat) Format a vector according to a number of vector format settings.(package private) Vector<?,?, ?, ?, ?> vector()Return the value as a vector.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
-
VectorFormatter
VectorFormatter(Vector<?, ?, ?, ?, ?> vector, VectorFormatContext ctx) - Parameters:
vector- the quantity to formatctx- the format context
-
-
Method Details
-
vector
Vector<?,?, vector()?, ?, ?> Return the value as a vector.- Returns:
- the value as a vector
-
format
Format a vector according to a number of vector 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:
vector- the vector to formatvectorFormat- the format to apply to the vector- Returns:
- a String with a formatted vector, matching the vector format settings as closely as possible
-
format
Format an absolute vector according to a number of vector 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:
absVector- the absolute vector to formatvectorFormat- the format to apply to the vector- Returns:
- a String with a formatted vector, matching the vector format settings as closely as possible
-
format
String format()Return the vector, formatted according to the context settings.- Specified by:
formatin classFormatter<VectorFormatContext>- Returns:
- the formatted vector
-