Package tech.units.indriya.format
Interface QuantityFormat
- All Known Implementing Classes:
AbstractQuantityFormat
,NumberSpaceQuantityFormat
,SimpleQuantityFormat
public interface QuantityFormat
Formats instances of Quantity
.
Synchronization
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:
- 0.3, 26 January, 2018
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionformat
(javax.measure.Quantity<?> quantity, Appendable dest) Formats the specified quantity into anAppendable
.default boolean
javax.measure.Quantity
<?> parse
(CharSequence csq) Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
.javax.measure.Quantity
<?> parse
(CharSequence csq, ParsePosition cursor) 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.dest
- the appendable destination.- Returns:
- the specified
Appendable
. - Throws:
IOException
- if an I/O exception occurs.
-
parse
javax.measure.Quantity<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException, javax.measure.format.ParserException Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
. If parsing succeeds, then the index of thecursor
argument is updated to the index after the last character used.- Parameters:
csq
- theCharSequence
to parse.cursor
- the cursor holding the current parsing index.- 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).javax.measure.format.ParserException
-
parse
Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
. If parsing succeeds, then the index of thecursor
argument is updated to the index after the last character used.- Parameters:
csq
- theCharSequence
to parse.cursor
- the cursor holding the current parsing index.- 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).javax.measure.format.ParserException
-
isLocaleSensitive
default boolean 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.
-