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.0, 3 July, 2020
- Author:
- Werner Keil, Thodoris Bais
- See Also:
Quantity
-
Method Summary
Modifier and Type Method Description String
format(Quantity<?> quantity)
Formats the specifiedQuantity
.Appendable
format(Quantity<?> quantity, Appendable destination)
Formats the specified quantity into anAppendable
.default boolean
isLocaleSensitive()
Quantity<?>
parse(CharSequence csq)
Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
.Quantity<?>
parse(CharSequence csq, ParsePosition pos)
Parses a portion of the specifiedCharSequence
from 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
- theQuantity
to format, notnull
- Returns:
- the string representation using the settings of this
QuantityFormat
.
-
parse
Quantity<?> parse(CharSequence csq, ParsePosition pos) throws IllegalArgumentException, MeasurementParseExceptionParses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
. If parsing succeeds, then the index of thepos
argument is updated to the index after the last character used.- Parameters:
csq
- theCharSequence
to 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:
IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).MeasurementParseException
-
parse
Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
.- Parameters:
csq
- theCharSequence
to parse.- Returns:
- the quantity parsed from the specified character sub-sequence.
- Throws:
IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).MeasurementParseException
-
isLocaleSensitive
Returnstrue
if thisQuantityFormat
depends on aLocale
to 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.
-