Interface MeasurementServiceProvider

All Known Implementing Classes:
DelegateMeasurementServiceProvider, IndriyaMeasurementServiceProvider

public interface MeasurementServiceProvider
API for interacting with Units of Measurement services.
Version:
1.0
Author:
matt
  • Method Summary

    Modifier and Type
    Method
    Description
    javax.measure.spi.FormatService
    Returns the service to obtain UnitFormat and QuantityFormat or null if none.
    <Q extends javax.measure.Quantity<Q>>
    javax.measure.spi.QuantityFactory<Q>
    Returns a factory for the given Quantity type.
    javax.measure.spi.SystemOfUnitsService
    Returns the service to obtain a SystemOfUnits, or null if none.
    javax.measure.spi.UnitFormatService
    Returns the service to obtain a UnitFormat, or null if none.
    <Q extends javax.measure.Quantity<Q>>
    javax.measure.Quantity<Q>
    quantityForUnit(Number value, javax.measure.Unit<Q> unit)
    Get a quantity for a given number and unit.
  • Method Details

    • getSystemOfUnitsService

      javax.measure.spi.SystemOfUnitsService getSystemOfUnitsService()
      Returns the service to obtain a SystemOfUnits, or null if none.
      Returns:
      the service to obtain a SystemOfUnits, or null.
    • getFormatService

      javax.measure.spi.FormatService getFormatService()
      Returns the service to obtain UnitFormat and QuantityFormat or null if none.
      Returns:
      the service to obtain a UnitFormat and QuantityFormat, or null.
    • getUnitFormatService

      javax.measure.spi.UnitFormatService getUnitFormatService()
      Returns the service to obtain a UnitFormat, or null if none.

      This API is deprecated in javax.measure 2.0, but the reference implementation exposes some parsing features only through this API (UCUM) so it is repeated here.

      Returns:
      the service to obtain a UnitFormat, or null.
    • getQuantityFactory

      <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getQuantityFactory(Class<Q> quantity)
      Returns a factory for the given Quantity type.
      Type Parameters:
      Q - the type of the Quantity instances created by the factory
      Parameters:
      quantity - the quantity type
      Returns:
      the QuantityFactory for the given type
    • quantityForUnit

      <Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> quantityForUnit(Number value, javax.measure.Unit<Q> unit)
      Get a quantity for a given number and unit.
      Type Parameters:
      Q - the quantity type
      Parameters:
      value - the quantity amount
      unit - the quantity unit
      Returns:
      the quantity, or null if one cannot be obtained