Class SingleUnitImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Determine the power of theSingleUnit
.private int
Simple unit index, unique for every simple unit, -1 for the dimensionless unit.private String
SimpleUnit is the simplest form of a Unit.private MeasureUnit.MeasurePrefix
SI or binary prefix. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
(package private) int
compareTo
(SingleUnitImpl other) Compare this SingleUnitImpl to another SingleUnitImpl for the sake of sorting and coalescing.copy()
int
int
getIndex()
Generates a neutral identifier string for a single unit which means we do not include the dimension signal.(package private) boolean
isCompatibleWith
(SingleUnitImpl other) Checks whether this SingleUnitImpl is compatible with another for the purpose of coalescing.void
setDimensionality
(int dimensionality) void
setPrefix
(MeasureUnit.MeasurePrefix unitPrefix) void
setSimpleUnit
(int simpleUnitIndex, String[] simpleUnits)
-
Field Details
-
index
private int indexSimple unit index, unique for every simple unit, -1 for the dimensionless unit. This is an index into a string list in unit.txt {ConversionUnits}.The default value is -1, meaning the dimensionless unit: isDimensionless() will return true, until index is changed.
-
simpleUnitID
SimpleUnit is the simplest form of a Unit. For example, for "square-millimeter", the simple unit would be "meter"ÒThe default value is "", meaning the dimensionless unit: isDimensionless() will return true, until index is changed.
-
dimensionality
private int dimensionalityDetermine the power of theSingleUnit
. For example, for "square-meter", the dimensionality will be2
.NOTE: Default dimensionality is 1.
-
unitPrefix
SI or binary prefix.
-
-
Constructor Details
-
SingleUnitImpl
public SingleUnitImpl()
-
-
Method Details
-
copy
-
build
-
getNeutralIdentifier
Generates a neutral identifier string for a single unit which means we do not include the dimension signal. -
compareTo
Compare this SingleUnitImpl to another SingleUnitImpl for the sake of sorting and coalescing.Sort order of units is specified by UTS #35 (https://unicode.org/reports/tr35/tr35-info.html#Unit_Identifier_Normalization).
Takes the sign of dimensionality into account, but not the absolute value: per-meter is not considered the same as meter, but meter is considered the same as square-meter.
The dimensionless unit generally does not get compared, but if it did, it would sort before other units by virtue of index being invalid input: '<' 0 and dimensionality not being negative.
-
isCompatibleWith
Checks whether this SingleUnitImpl is compatible with another for the purpose of coalescing.Units with the same base unit and SI or binary prefix should match, except that they must also have the same dimensionality sign, such that we don't merge numerator and denominator.
-
getSimpleUnitID
-
setSimpleUnit
-
getDimensionality
public int getDimensionality() -
setDimensionality
public void setDimensionality(int dimensionality) -
getPrefix
-
setPrefix
-
getIndex
public int getIndex()
-