Interface QuantityFormat

  • All Known Implementing Classes:
    AbstractQuantityFormat, NumberSpaceQuantityFormat, SimpleQuantityFormat

    public interface QuantityFormat

    Formats 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.Appendable format​(javax.measure.Quantity<?> quantity, java.lang.Appendable dest)
      Formats the specified quantity into an Appendable.
      default boolean isLocaleSensitive()
      Returns true if this QuantityFormat depends on a Locale to perform its tasks.
      javax.measure.Quantity<?> parse​(java.lang.CharSequence csq)
      Parses a portion of the specified CharSequence from the specified position to produce a Quantity.
      javax.measure.Quantity<?> parse​(java.lang.CharSequence csq, java.text.ParsePosition cursor)
      Parses a portion of the specified CharSequence from the specified position to produce a Quantity.
    • Method Detail

      • format

        java.lang.Appendable format​(javax.measure.Quantity<?> quantity,
                                    java.lang.Appendable dest)
                             throws java.io.IOException
        Formats the specified quantity into an Appendable.
        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.ParserException
        Parses a portion of the specified CharSequence from the specified position to produce a Quantity. 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.
        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.ParserException
        Parses a portion of the specified CharSequence from the specified position to produce a Quantity. 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.
        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()
        Returns true if this QuantityFormat depends on a Locale to perform its tasks.

        In environments that do not support a Locale, e.g. Java ME, this usually returns false.

        Returns:
        Whether this format depends on the locale.