Class SimpleQuantityFormat
java.lang.Object
java.text.Format
tech.units.indriya.format.AbstractQuantityFormat
tech.units.indriya.format.SimpleQuantityFormat
- All Implemented Interfaces:
Serializable, Cloneable, QuantityFormat, tech.uom.lib.common.function.Parser<CharSequence, ComparableQuantity>
A simple implementation of QuantityFormat
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final SimpleQuantityFormatHolds the default format instance.private static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat(javax.measure.Quantity quantity, Appendable dest) Formats the specified quantity into anAppendable.static SimpleQuantityFormatReturns the quantity format for the default locale.parse(CharSequence csq) Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.(package private) AbstractQuantity<?> parse(CharSequence csq, int index) Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.parse(CharSequence csq, ParsePosition cursor) Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.Methods inherited from class AbstractQuantityFormat
format, format, parseObjectMethods inherited from class Format
clone, format, formatToCharacterIterator, parseObjectMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface QuantityFormat
isLocaleSensitive
-
Field Details
-
DEFAULT
Holds the default format instance. -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
SimpleQuantityFormat
public SimpleQuantityFormat()
-
-
Method Details
-
format
Description copied from class:AbstractQuantityFormatFormats the specified quantity into anAppendable.- Specified by:
formatin interfaceQuantityFormat- Specified by:
formatin classAbstractQuantityFormat- Parameters:
quantity- the quantity to format.dest- the appendable destination.- Returns:
- the specified
Appendable. - Throws:
IOException- if an I/O exception occurs.
-
parse
public ComparableQuantity<?> parse(CharSequence csq, ParsePosition cursor) throws javax.measure.format.ParserException Description copied from class:AbstractQuantityFormatParses a portion of the specifiedCharSequencefrom the specified position to produce an object. If parsing succeeds, then the index of thecursorargument is updated to the index after the last character used.- Specified by:
parsein interfaceQuantityFormat- Specified by:
parsein classAbstractQuantityFormat- Parameters:
csq- theCharSequenceto parse.cursor- the cursor holding the current parsing index.- Returns:
- the object parsed from the specified character sub-sequence.
- Throws:
javax.measure.format.ParserException
-
parse
Description copied from class:AbstractQuantityFormatParses a portion of the specifiedCharSequencefrom the specified position to produce an object. If parsing succeeds, then the index of thecursorargument is updated to the index after the last character used.- Specified by:
parsein classAbstractQuantityFormat- Parameters:
csq- theCharSequenceto parse.index- the current parsing index.- Returns:
- the object parsed from the specified character sub-sequence.
- Throws:
javax.measure.format.ParserException
-
parse
Description copied from class:AbstractQuantityFormatParses a portion of the specifiedCharSequencefrom the specified position to produce an object. If parsing succeeds, then the index of thecursorargument is updated to the index after the last character used.- Specified by:
parsein interfacetech.uom.lib.common.function.Parser<CharSequence, ComparableQuantity>- Specified by:
parsein interfaceQuantityFormat- Specified by:
parsein classAbstractQuantityFormat- Parameters:
csq- theCharSequenceto parse.- Returns:
- the object parsed from the specified character sub-sequence.
- Throws:
javax.measure.format.ParserException
-
getInstance
Returns the quantity format for the default locale. The default format assumes the quantity is composed of a decimal number and aUnitseparated by whitespace(s).- Returns:
MeasureFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())
-