Class AbstractQuantityFormat

    • Method Detail

      • format

        public abstract Appendable format​(javax.measure.Quantity<?> quantity,
                                          Appendable dest)
                                   throws IOException
        Formats the specified quantity into an Appendable.
        Specified by:
        format in interface javax.measure.format.QuantityFormat
        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 javax.measure.Quantity<?> parse​(CharSequence csq,
                                                        ParsePosition cursor)
                                                 throws IllegalArgumentException,
                                                        javax.measure.format.MeasurementParseException
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Specified by:
        parse in interface javax.measure.format.QuantityFormat
        Parameters:
        csq - the CharSequence to 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.MeasurementParseException
      • parse

        public abstract javax.measure.Quantity<?> parse​(CharSequence csq)
                                                 throws javax.measure.format.MeasurementParseException
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Specified by:
        parse in interface tech.uom.lib.common.function.Parser<CharSequence,​javax.measure.Quantity>
        Specified by:
        parse in interface javax.measure.format.QuantityFormat
        Parameters:
        csq - the CharSequence to parse.
        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.MeasurementParseException
      • parse

        protected abstract javax.measure.Quantity<?> parse​(CharSequence csq,
                                                           int index)
                                                    throws IllegalArgumentException,
                                                           javax.measure.format.MeasurementParseException
        Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
        Parameters:
        csq - the CharSequence to parse.
        index - 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.MeasurementParseException
      • format

        public final String format​(javax.measure.Quantity<?> quantity)
        Formats an object to produce a string. This is equivalent to
        format(unit, new StringBuilder()).toString();
        Specified by:
        format in interface javax.measure.format.QuantityFormat
        Parameters:
        quantity - The quantity to format
        Returns:
        Formatted string.
      • format

        protected final StringBuffer format​(ComparableQuantity<?> quantity,
                                            StringBuffer dest)
        Convenience method equivalent to #format(ComparableQuantity, Appendable) except it does not raise an IOException.
        Parameters:
        quantity - the quantity to format.
        dest - the appendable destination.
        Returns:
        the specified StringBuilder.
      • formatCompound

        protected abstract StringBuffer formatCompound​(CompoundQuantity<?> comp,
                                                       StringBuffer dest)
        Convenience method equivalent to #format(CompoundQuantity, Appendable) except it does not raise an IOException.
        Parameters:
        comp - the composite quantity to format.
        dest - the appendable destination.
        Returns:
        the specified StringBuilder.