Interface UnitConversionSession

All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession

public interface UnitConversionSession extends OsidSession

This session defines methods to convert units across measurement systems.

  • Method Details

    • canConvertUnits

      boolean canConvertUnits()
      Tests if this user can perform unit conversions. A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in a PERMISSION_DENIED . This is intended as a hint to an application that may opt not to offer lookup operations.
      Returns:
      false if conversion methods are not authorized, true otherwise
      Compliance:
      mandatory - This method must be implemented.
    • convertUnit

      BigDecimal convertUnit(BigDecimal sourceUnit, Type sourceUnitType, Type targetUnitType) throws OperationFailedException, PermissionDeniedException
      Convert a unit of measurement.
      Parameters:
      sourceUnit - the measure to convert
      sourceUnitType - the type of measure specified
      targetUnitType - the type of converted measure
      Returns:
      resulting measure
      Throws:
      NullArgumentException - null argument provided
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - LocaleManager.supportsUnitTypesForConversion(measureType, conversionType) is false
      Compliance:
      mandatory - This method must be implemented.
    • convertUnits

      BigDecimal[] convertUnits(BigDecimal[] sourceUnits, Type sourceUnitType, Type targetUnitType) throws OperationFailedException, PermissionDeniedException
      Convert units of measurement.
      Parameters:
      sourceUnits - the measures to convert
      sourceUnitType - the type of measure specified
      targetUnitType - the type of converted measure
      Returns:
      resulting measures
      Throws:
      NullArgumentException - null argument provided
      OperationFailedException - unable to complete request
      PermissionDeniedException - authorization failure
      UnsupportedException - LocaleManager.supportsUnitTypesForConversion(measureType, conversionType) is false
      Compliance:
      mandatory - This method must be implemented.