Package ucar.units
Class BaseUnit
- java.lang.Object
-
- ucar.units.UnitImpl
-
- ucar.units.DerivedUnitImpl
-
- ucar.units.BaseUnit
-
- All Implemented Interfaces:
Serializable
,Base
,DerivableUnit
,DerivedUnit
,Unit
- Direct Known Subclasses:
UnknownUnit
@Immutable public class BaseUnit extends DerivedUnitImpl implements Base
Provides support for base units.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.units.UnitImpl
UnitImpl.MyConverter
-
-
Field Summary
-
Fields inherited from class ucar.units.DerivedUnitImpl
DIMENSIONLESS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseUnit(UnitName id, BaseQuantity baseQuantity)
Constructs from identifiers and a base quantity.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BaseQuantity
getBaseQuantity()
Returns the base quantity associated with this base unit.String
getID()
Returns the identifier for this base unit.static BaseUnit
getOrCreate(UnitName id, BaseQuantity baseQuantity)
Factory method for creating a new BaseUnit or obtaining a previously-created one.boolean
isDimensionless()
Indicates if this base unit is dimensionless.String
toString()
Returns the string representation of this base unit.-
Methods inherited from class ucar.units.DerivedUnitImpl
clone, equals, fromDerivedUnit, fromDerivedUnit, fromDerivedUnit, fromDerivedUnit, getCanonicalString, getDerivedUnit, getDimension, getQuantityDimension, hashCode, isCompatible, isReciprocalOf, myDivideBy, myDivideInto, myMultiplyBy, myRaiseTo, setDimension, toDerivedUnit, toDerivedUnit, toDerivedUnit, toDerivedUnit
-
Methods inherited from class ucar.units.UnitImpl
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getConverterTo, getName, getPlural, getSymbol, getUnitName, log, makeLabel, multiplyBy, multiplyBy, raiseTo, shiftTo, shiftTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.units.Unit
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getConverterTo, getName, getPlural, getSymbol, getUnitName, log, makeLabel, multiplyBy, multiplyBy, raiseTo, shiftTo, shiftTo
-
-
-
-
Constructor Detail
-
BaseUnit
protected BaseUnit(UnitName id, BaseQuantity baseQuantity) throws NameException
Constructs from identifiers and a base quantity.- Parameters:
id
- The identifiers for the base unit.id.getSymbol()
shall not returnnull
.baseQuantity
- The base quantity of the base unit.- Throws:
NameException
-id.getSymbol()
returnednull
.
-
-
Method Detail
-
getOrCreate
public static BaseUnit getOrCreate(UnitName id, BaseQuantity baseQuantity) throws NameException, UnitExistsException
Factory method for creating a new BaseUnit or obtaining a previously-created one.- Parameters:
id
- The identifier for the base unit.id.getSymbol()
shall not returnnull
.baseQuantity
- The base quantity of the base unit.- Throws:
NameException
-id.getSymbol()
returnednull
.UnitExistsException
- Attempt to incompatibly redefine an existing base unit.
-
getBaseQuantity
public final BaseQuantity getBaseQuantity()
Returns the base quantity associated with this base unit.- Returns:
- The base quantity associated with this base unit.
-
getID
public final String getID()
Returns the identifier for this base unit. This is identical togetSymbol()
.
-
toString
public final String toString()
Returns the string representation of this base unit. This is identical togetID()
.- Specified by:
toString
in interfaceUnit
- Overrides:
toString
in classDerivedUnitImpl
- Returns:
- The string representation of this base unit.
-
isDimensionless
public boolean isDimensionless()
Indicates if this base unit is dimensionless.- Specified by:
isDimensionless
in interfaceBase
- Specified by:
isDimensionless
in interfaceUnit
- Overrides:
isDimensionless
in classDerivedUnitImpl
- Returns:
true
if and only if this base unit is dimensionless (e.g. "radian").
-
-