Package tech.units.indriya.format
Class AbstractQuantityFormat
- java.lang.Object
-
- java.text.Format
-
- tech.units.indriya.format.AbstractQuantityFormat
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,QuantityFormat,tech.uom.lib.common.function.Parser<java.lang.CharSequence,ComparableQuantity>
- Direct Known Subclasses:
NumberSpaceQuantityFormat,SimpleQuantityFormat
public abstract class AbstractQuantityFormat extends java.text.Format implements QuantityFormat, tech.uom.lib.common.function.Parser<java.lang.CharSequence,ComparableQuantity>
This class provides the interface for formatting and parsing
quantities.- Since:
- 1.0
- Version:
- 1.1, $Date: 2018-04-06 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description AbstractQuantityFormat()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringBufferformat(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)abstract java.lang.Appendableformat(javax.measure.Quantity<?> quantity, java.lang.Appendable dest)Formats the specified quantity into anAppendable.java.lang.StringBuilderformat(AbstractQuantity<?> quantity, java.lang.StringBuilder dest)Convenience method equivalent to#format(AbstractQuantity, Appendable)except it does not raise an IOException.abstract ComparableQuantity<?>parse(java.lang.CharSequence csq)Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.(package private) abstract ComparableQuantity<?>parse(java.lang.CharSequence csq, int index)Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.abstract ComparableQuantity<?>parse(java.lang.CharSequence csq, java.text.ParsePosition cursor)Parses a portion of the specifiedCharSequencefrom the specified position to produce an object.javax.measure.Quantity<?>parseObject(java.lang.String source, java.text.ParsePosition pos)-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface tech.units.indriya.format.QuantityFormat
isLocaleSensitive
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
format
public abstract java.lang.Appendable format(javax.measure.Quantity<?> quantity, java.lang.Appendable dest) throws java.io.IOExceptionFormats the specified quantity into anAppendable.- Specified by:
formatin interfaceQuantityFormat- 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
public abstract ComparableQuantity<?> parse(java.lang.CharSequence csq, java.text.ParsePosition cursor) throws java.lang.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:
java.lang.IllegalArgumentException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.ParserException
-
parse
public abstract ComparableQuantity<?> parse(java.lang.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<java.lang.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:
java.lang.IllegalArgumentException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).javax.measure.format.ParserException
-
parse
abstract ComparableQuantity<?> parse(java.lang.CharSequence csq, int index) throws java.lang.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.- Parameters:
csq- theCharSequenceto parse.index- the current parsing index.- Returns:
- the object 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
-
format
public final java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)- Specified by:
formatin classjava.text.Format
-
parseObject
public final javax.measure.Quantity<?> parseObject(java.lang.String source, java.text.ParsePosition pos)- Specified by:
parseObjectin classjava.text.Format
-
format
public final java.lang.StringBuilder format(AbstractQuantity<?> quantity, java.lang.StringBuilder dest)
Convenience method equivalent to#format(AbstractQuantity, Appendable)except it does not raise an IOException.- Parameters:
quantity- the quantity to format.dest- the appendable destination.- Returns:
- the specified
StringBuilder.
-
-