Interface UnitConversionSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
This session defines methods to convert units across measurement systems.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTests if this user can perform unit conversions.convertUnit(BigDecimal sourceUnit, Type sourceUnitType, Type targetUnitType) Convert a unit of measurement.convertUnits(BigDecimal[] sourceUnits, Type sourceUnitType, Type targetUnitType) Convert units of measurement.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
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 aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer lookup operations.- Returns:
falseif conversion methods are not authorized,trueotherwise- 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 convertsourceUnitType- the type of measure specifiedtargetUnitType- the type of converted measure- Returns:
- resulting measure
- Throws:
NullArgumentException-nullargument providedOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-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 convertsourceUnitType- the type of measure specifiedtargetUnitType- the type of converted measure- Returns:
- resulting measures
- Throws:
NullArgumentException-nullargument providedOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-LocaleManager.supportsUnitTypesForConversion(measureType, conversionType)is false- Compliance:
mandatory- This method must be implemented.
-