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

    Modifier and Type
    Method
    Description
    format(javax.measure.Quantity<?> quantity, Appendable dest)
    Formats the specified quantity into an Appendable.
    default boolean
    Returns true if this QuantityFormat depends on a Locale to perform its tasks.
    javax.measure.Quantity<?>
    Parses a portion of the specified CharSequence from the specified position to produce a Quantity.
    javax.measure.Quantity<?>
    Parses a portion of the specified CharSequence from the specified position to produce a Quantity.
  • Method Details

    • format

      Appendable format(javax.measure.Quantity<?> quantity, Appendable dest) throws IOException
      Formats the specified quantity into an Appendable.
      Parameters:
      quantity - the quantity to format.
      dest - the appendable destination.
      Returns:
      the specified Appendable.
      Throws:
      IOException - if an I/O exception occurs.
    • parse

      javax.measure.Quantity<?> parse(CharSequence csq, ParsePosition cursor) throws 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:
      IllegalArgumentException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
      javax.measure.format.ParserException
    • parse

      javax.measure.Quantity<?> parse(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:
      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.