Top Description Fields Constructors Methods
com.ibm.icu.impl.units

public Class SingleUnitImpl

extends Object
Class Inheritance
Imports
com.ibm.icu.util.MeasureUnit

A class representing a single unit (optional SI or binary prefix, and dimensionality).

Field Summary

Modifier and TypeField and Description
private int
dimensionality

Determine the power of the SingleUnit.

private int
index

Simple unit index, unique for every simple unit, -1 for the dimensionless unit.

private String
simpleUnitID

SimpleUnit is the simplest form of a Unit.

private MeasureUnit.MeasurePrefix
unitPrefix

SI or binary prefix.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public MeasureUnit
pack-priv int
compareTo(SingleUnitImpl other)

Compare this SingleUnitImpl to another SingleUnitImpl for the sake of sorting and coalescing.

public SingleUnitImpl
copy()

public int
public int
public String
getNeutralIdentifier()

Generates a neutral identifier string for a single unit which means we do not include the dimension signal.

public MeasureUnit.MeasurePrefix
public String
pack-priv boolean
isCompatibleWith(SingleUnitImpl other)

Checks whether this SingleUnitImpl is compatible with another for the purpose of coalescing.

public void
setDimensionality(int dimensionality)

public void
public void
setSimpleUnit(int simpleUnitIndex, String[] simpleUnits)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dimensionalityback to summary
private int dimensionality

Determine the power of the SingleUnit. For example, for "square-meter", the dimensionality will be 2.

Note

Default dimensionality is 1.

indexback to summary
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.

simpleUnitIDback to summary
private 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.

unitPrefixback to summary
private MeasureUnit.MeasurePrefix unitPrefix

SI or binary prefix.

Constructor Detail

SingleUnitImplback to summary
public SingleUnitImpl()

Method Detail

buildback to summary
public MeasureUnit build()
compareToback to summary
pack-priv 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.

copyback to summary
public SingleUnitImpl copy()
getDimensionalityback to summary
public int getDimensionality()
getIndexback to summary
public int getIndex()
getNeutralIdentifierback to summary
public String getNeutralIdentifier()

Generates a neutral identifier string for a single unit which means we do not include the dimension signal.

getPrefixback to summary
public MeasureUnit.MeasurePrefix getPrefix()
getSimpleUnitIDback to summary
public String getSimpleUnitID()
isCompatibleWithback to summary
pack-priv 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.

setDimensionalityback to summary
public void setDimensionality(int dimensionality)
setPrefixback to summary
public void setPrefix(MeasureUnit.MeasurePrefix unitPrefix)
setSimpleUnitback to summary
public void setSimpleUnit(int simpleUnitIndex, String[] simpleUnits)