Package tech.units.indriya.format
Interface QuantityFormat
-
- All Known Implementing Classes:
AbstractQuantityFormat,NumberSpaceQuantityFormat,SimpleQuantityFormat
public interface QuantityFormatFormats 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.Appendableformat(javax.measure.Quantity<?> quantity, java.lang.Appendable dest)Formats the specified quantity into anAppendable.default booleanisLocaleSensitive()javax.measure.Quantity<?>parse(java.lang.CharSequence csq)Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity.javax.measure.Quantity<?>parse(java.lang.CharSequence csq, java.text.ParsePosition cursor)Parses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity.
-
-
-
Method Detail
-
format
java.lang.Appendable format(javax.measure.Quantity<?> quantity, java.lang.Appendable dest) throws java.io.IOExceptionFormats 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.ParserExceptionParses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity. If parsing succeeds, then the index of thecursorargument is updated to the index after the last character used.- Parameters:
csq- theCharSequenceto 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.ParserExceptionParses a portion of the specifiedCharSequencefrom the specified position to produce aQuantity. If parsing succeeds, then the index of thecursorargument is updated to the index after the last character used.- Parameters:
csq- theCharSequenceto 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()
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.
-
-