Class SimpleQuantityFormat

All Implemented Interfaces:
Serializable, Cloneable, QuantityFormat, tech.uom.lib.common.function.Parser<CharSequence,ComparableQuantity>

public class SimpleQuantityFormat extends AbstractQuantityFormat
A simple implementation of QuantityFormat
See Also:
  • Field Details

  • Constructor Details

    • SimpleQuantityFormat

      public SimpleQuantityFormat()
  • Method Details

    • format

      public Appendable format(javax.measure.Quantity quantity, Appendable dest) throws IOException
      Description copied from class: AbstractQuantityFormat
      Formats the specified quantity into an Appendable.
      Specified by:
      format in interface QuantityFormat
      Specified by:
      format in class AbstractQuantityFormat
      Parameters:
      quantity - the quantity to format.
      dest - the appendable destination.
      Returns:
      the specified Appendable.
      Throws:
      IOException - if an I/O exception occurs.
    • parse

      public ComparableQuantity<?> parse(CharSequence csq, ParsePosition cursor) throws javax.measure.format.ParserException
      Description copied from class: AbstractQuantityFormat
      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 QuantityFormat
      Specified by:
      parse in class AbstractQuantityFormat
      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:
      javax.measure.format.ParserException
    • parse

      AbstractQuantity<?> parse(CharSequence csq, int index) throws javax.measure.format.ParserException
      Description copied from class: AbstractQuantityFormat
      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 class AbstractQuantityFormat
      Parameters:
      csq - the CharSequence to parse.
      index - the current parsing index.
      Returns:
      the object parsed from the specified character sub-sequence.
      Throws:
      javax.measure.format.ParserException
    • parse

      public ComparableQuantity<?> parse(CharSequence csq) throws javax.measure.format.ParserException
      Description copied from class: AbstractQuantityFormat
      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,ComparableQuantity>
      Specified by:
      parse in interface QuantityFormat
      Specified by:
      parse in class AbstractQuantityFormat
      Parameters:
      csq - the CharSequence to parse.
      Returns:
      the object parsed from the specified character sub-sequence.
      Throws:
      javax.measure.format.ParserException
    • getInstance

      public static SimpleQuantityFormat getInstance()
      Returns the quantity format for the default locale. The default format assumes the quantity is composed of a decimal number and a Unit separated by whitespace(s).
      Returns:
      MeasureFormat.getInstance(NumberFormat.getInstance(), UnitFormat.getInstance())