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:
Quantity
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Appendable
format(javax.measure.Quantity<?> quantity, java.lang.Appendable dest)
Formats the specified quantity into anAppendable
.default boolean
isLocaleSensitive()
javax.measure.Quantity<?>
parse(java.lang.CharSequence csq)
Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
.javax.measure.Quantity<?>
parse(java.lang.CharSequence csq, java.text.ParsePosition cursor)
Parses a portion of the specifiedCharSequence
from the specified position to produce aQuantity
.
-
-
-
Method Detail
-
format
java.lang.Appendable format(javax.measure.Quantity<?> quantity, java.lang.Appendable dest) throws java.io.IOException
Formats the specified quantity into anAppendable
.- Parameters:
quantity
- the quantity to format.dest
- the appendable destination.- Returns:
- the specified
Appendable
. - Throws:
java.io.IOException
- if an I/O exception occurs.
-
parse
javax.measure.Quantity<?> parse(java.lang.CharSequence csq, java.text.ParsePosition cursor) throws java.lang.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:
java.lang.IllegalArgumentException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.ParserException
-
parse
javax.measure.Quantity<?> parse(java.lang.CharSequence csq) throws 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:
java.lang.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.
-
-