Package javax.measure.format
Interface QuantityFormat
public interface QuantityFormat
Formats instances of
Quantity.
Instances of this class are not required to be thread-safe. It is recommended to use separate format instances for each thread. If multiple threads
access a format concurrently, it must be synchronized externally.- Since:
- 2.0
- Version:
- 1.1, 20 May, 2023
- Author:
- Werner Keil, Thodoris Bais
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionFormats the specifiedQuantity.format(Quantity<?> quantity, Appendable destination) Formats the specified quantity into anAppendable.default booleanQuantity<?>parse(CharSequence csq) Parses the specifiedCharSequenceto produce aQuantity.Quantity<?>parse(CharSequence csq, ParsePosition pos) Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity.
-
Method Details
-
format
Formats the specified quantity into anAppendable.- Parameters:
quantity- the quantity to format.destination- the appendable destination.- Returns:
- the specified
Appendable. - Throws:
IOException- if an I/O exception occurs.
-
format
Formats the specifiedQuantity.- Parameters:
quantity- theQuantityto format, notnull- Returns:
- the string representation using the settings of this
QuantityFormat.
-
parse
Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity. If parsing succeeds, then the index of theposargument is updated to the index after the last character used.- Parameters:
csq- theCharSequenceto parse.pos- a ParsePosition object holding the current parsing index and error parsing index information as described above.- Returns:
- the quantity parsed from the specified character sub-sequence.
- Throws:
MeasurementParseException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
-
parse
Parses the specifiedCharSequenceto produce aQuantity.The parse must complete normally and parse the entire text. If the parse completes without reading the entire length of the text, an exception is thrown. If any other problem occurs during parsing, an exception is thrown.
- Parameters:
csq- theCharSequenceto parse.- Returns:
- the quantity parsed from the specified character sub-sequence.
- Throws:
MeasurementParseException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
-
isLocaleSensitive
Returnstrueif thisQuantityFormatdepends on aLocaleto perform its tasks.In environments that do not support a
Locale, e.g. Java ME, this usually returnsfalse.- Returns:
- whether this format depends on the locale.
-