Class SingleUnitImpl
- java.lang.Object
-
- com.ibm.icu.impl.units.SingleUnitImpl
-
public class SingleUnitImpl extends java.lang.Object
A class representing a single unit (optional SI or binary prefix, and dimensionality).
-
-
Field Summary
Fields Modifier and Type Field Description private int
dimensionality
Determine the power of theSingleUnit
.private int
index
Simple unit index, unique for every simple unit, -1 for the dimensionless unit.private java.lang.String
simpleUnitID
SimpleUnit is the simplest form of a Unit.private MeasureUnit.MeasurePrefix
unitPrefix
SI or binary prefix.
-
Constructor Summary
Constructors Constructor Description SingleUnitImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MeasureUnit
build()
(package private) int
compareTo(SingleUnitImpl other)
Compare this SingleUnitImpl to another SingleUnitImpl for the sake of sorting and coalescing.SingleUnitImpl
copy()
int
getDimensionality()
int
getIndex()
java.lang.String
getNeutralIdentifier()
Generates a neutral identifier string for a single unit which means we do not include the dimension signal.MeasureUnit.MeasurePrefix
getPrefix()
java.lang.String
getSimpleUnitID()
(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, java.lang.String[] simpleUnits)
-
-
-
Field Detail
-
index
private int index
Simple 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
private java.lang.String 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 dimensionality
Determine the power of theSingleUnit
. For example, for "square-meter", the dimensionality will be2
.NOTE: Default dimensionality is 1.
-
unitPrefix
private MeasureUnit.MeasurePrefix unitPrefix
SI or binary prefix.
-
-
Method Detail
-
copy
public SingleUnitImpl copy()
-
build
public MeasureUnit build()
-
getNeutralIdentifier
public java.lang.String getNeutralIdentifier()
Generates a neutral identifier string for a single unit which means we do not include the dimension signal.
-
compareTo
int compareTo(SingleUnitImpl other)
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 < 0 and dimensionality not being negative.
-
isCompatibleWith
boolean isCompatibleWith(SingleUnitImpl other)
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
public java.lang.String getSimpleUnitID()
-
setSimpleUnit
public void setSimpleUnit(int simpleUnitIndex, java.lang.String[] simpleUnits)
-
getDimensionality
public int getDimensionality()
-
setDimensionality
public void setDimensionality(int dimensionality)
-
getPrefix
public MeasureUnit.MeasurePrefix getPrefix()
-
setPrefix
public void setPrefix(MeasureUnit.MeasurePrefix unitPrefix)
-
getIndex
public int getIndex()
-
-