Package javax.measure.format
Interface QuantityFormat
-
public interface QuantityFormat
Formats instances ofQuantity. 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:
Quantity
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Stringformat(Quantity<?> quantity)Formats the specifiedQuantity.java.lang.Appendableformat(Quantity<?> quantity, java.lang.Appendable destination)Formats the specified quantity into anAppendable.default booleanisLocaleSensitive()Quantity<?>parse(java.lang.CharSequence csq)Parses the specifiedCharSequenceto produce aQuantity.Quantity<?>parse(java.lang.CharSequence csq, java.text.ParsePosition pos)Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity.
-
-
-
Method Detail
-
format
java.lang.Appendable format(Quantity<?> quantity, java.lang.Appendable destination) throws java.io.IOException
Formats the specified quantity into anAppendable.- Parameters:
quantity- the quantity to format.destination- the appendable destination.- Returns:
- the specified
Appendable. - Throws:
java.io.IOException- if an I/O exception occurs.
-
format
java.lang.String format(Quantity<?> quantity)
Formats the specifiedQuantity.- Parameters:
quantity- theQuantityto format, notnull- Returns:
- the string representation using the settings of this
QuantityFormat.
-
parse
Quantity<?> parse(java.lang.CharSequence csq, java.text.ParsePosition pos) throws MeasurementParseException
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
Quantity<?> parse(java.lang.CharSequence csq) throws MeasurementParseException
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
default boolean 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.
-
-