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 Stringformat(Quantity<?> quantity)Formats the specifiedQuantity.Appendableformat(Quantity<?> quantity, Appendable destination)Formats the specified quantity into anAppendable.default booleanisLocaleSensitive()Quantity<?>parse(CharSequence csq)Parses a portion of the specifiedCharSequencefrom the specified position to 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
Quantity<?> parse(CharSequence csq, ParsePosition pos) throws IllegalArgumentException, MeasurementParseExceptionParses 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:
IllegalArgumentException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).MeasurementParseException
-
parse
Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity.- Parameters:
csq- theCharSequenceto 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
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.
-