Class AbstractQuantityFormat
java.lang.Object
java.text.Format
tech.units.indriya.format.AbstractQuantityFormat
- All Implemented Interfaces:
Serializable, Cloneable, QuantityFormat, tech.uom.lib.common.function.Parser<CharSequence, ComparableQuantity>
- Direct Known Subclasses:
NumberSpaceQuantityFormat, SimpleQuantityFormat
public abstract class AbstractQuantityFormat
extends Format
implements QuantityFormat, tech.uom.lib.common.function.Parser<CharSequence, ComparableQuantity>
This class provides the interface for formatting and parsing quantities.
- Since:
- 1.0
- Version:
- 1.1, $Date: 2018-04-06 $
- Author:
- Jean-Marie Dautelle, Werner Keil
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringBufferformat(Object obj, StringBuffer toAppendTo, FieldPosition pos) abstract Appendableformat(javax.measure.Quantity<?> quantity, Appendable dest) Formats the specified quantity into anAppendable.final StringBuilderformat(AbstractQuantity<?> quantity, StringBuilder dest) Convenience method equivalent toexcept it does not raise an IOException.invalid reference
#format(AbstractQuantity, Appendable)abstract ComparableQuantity<?> parse(CharSequence csq) Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.abstract ComparableQuantity<?> parse(CharSequence csq, ParsePosition cursor) Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.final javax.measure.Quantity<?> parseObject(String source, ParsePosition pos) Methods 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
-
Constructor Details
-
AbstractQuantityFormat
public AbstractQuantityFormat()
-
-
Method Details
-
format
public abstract Appendable format(javax.measure.Quantity<?> quantity, Appendable dest) throws IOException Formats the specified quantity into anAppendable.- Specified by:
formatin interfaceQuantityFormat- Parameters:
quantity- the quantity to format.dest- the appendable destination.- Returns:
- the specified
Appendable. - Throws:
IOException- if an I/O exception occurs.
-
parse
public abstract ComparableQuantity<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException, javax.measure.format.ParserException Parses 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- Parameters:
csq- theCharSequenceto parse.cursor- the cursor holding the current parsing index.- Returns:
- the object 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
public abstract ComparableQuantity<?> parse(CharSequence csq) throws javax.measure.format.ParserException Parses 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- Parameters:
csq- theCharSequenceto parse.cursor- the cursor holding the current parsing index.- Returns:
- the object 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
-
format
-
parseObject
- Specified by:
parseObjectin classFormat
-
format
Convenience method equivalent toexcept it does not raise an IOException.invalid reference
#format(AbstractQuantity, Appendable)- Parameters:
quantity- the quantity to format.dest- the appendable destination.- Returns:
- the specified
StringBuilder.
-