Package org.openjdk.jmc.common.unit
Interface IUnit
- All Known Implementing Classes:
LinearUnit
,LinearUnit.Custom
,TimestampUnit
,TypedUnit
public interface IUnit
A unit of an affine unit system.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionString[]
Get alternate names for content assist matching.getAppendableSuffix
(boolean useBreakingSpace) Convenience method for (localized) formatters, to prepend a space togetLocalizedSymbol()
, if needed.Get the kind of quantity of this unit.Get the unit that the difference between two quantities in this unit will have.Persistable identifier, not to show interactively.In the real world, units are sometimes used ambiguously (like MB).Symbols for units are most often not locale dependent, but there are exceptions (like in French).boolean
isLinear()
If this unit is linear.quantity
(double numericalValue) Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
.quantity
(long numericalValue) Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
.Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
.valueTransformTo
(IUnit targetUnit) Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit
.
-
Field Details
-
EMPTY_STRING_ARRAY
-
-
Method Details
-
getContentType
KindOfQuantity<?> getContentType()Get the kind of quantity of this unit. -
quantity
Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
. -
quantity
Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
. -
quantity
Create a quantity expressed in this unit and with a numerical quantity value equal tonumericalValue
. -
valueTransformTo
Get a transform for transforming numerical quantity values expressed in this unit to numerical quantity values expressed intargetUnit
. This method is typically only used internally by the quantity implementations.- Throws:
IllegalArgumentException
- iftargetUnit
is not of the same kind of quantity
-
isLinear
boolean isLinear()If this unit is linear. That is, if quantities expressed in this unit and in units of the same kind can be added to and subtracted from each other, and the resulting quantity remains of the same kind.- Returns:
true
if and only if the unit is linear
-
getDeltaUnit
LinearUnit getDeltaUnit()Get the unit that the difference between two quantities in this unit will have. For linear units, this is always the unit itself.- Returns:
- the linear unit in which deltas of this unit is expressed
-
getIdentifier
String getIdentifier()Persistable identifier, not to show interactively.- Returns:
- the persistable (locale independent) identifier, or (possibly) null if this unit isn't persistable.
-
getLocalizedSymbol
String getLocalizedSymbol()Symbols for units are most often not locale dependent, but there are exceptions (like in French). Also, besides real persistable units, temporary units are sometimes constructed for display purposes, and they might vary due to internationalization, and conceivably language.While symbols normally don't contain any white space, spacing occur in circumstances like custom units. In this case, it is important that they are non-breaking spaces (
- Returns:
- the localized symbol of this unit.
-
getAppendableSuffix
Convenience method for (localized) formatters, to prepend a space togetLocalizedSymbol()
, if needed.- Parameters:
useBreakingSpace
- to use breaking space instead of the default, non-breaking space (only for edit)- Returns:
- a localized string to be appended to a number when displaying a quantity (including space, if non-empty).
-
getLocalizedDescription
String getLocalizedDescription()In the real world, units are sometimes used ambiguously (like MB). This description is intended to remove such ambiguity where needed.- Returns:
- a (possibly) localized unambiguous description of this unit
-
getAltLocalizedNames
String[] getAltLocalizedNames()Get alternate names for content assist matching. Note that these should never contain non-breaking spaces, only regular (breaking) spaces.- Returns:
- an array, possibly empty, of names with which to match for content assist, never
null
.
-