Package ucar.units
Class Dimension
- java.lang.Object
-
- ucar.units.Dimension
-
- Direct Known Subclasses:
QuantityDimension,UnitDimension
public abstract class Dimension extends Object
Provides support for the concept of "dimension": pairs of base entities and exponents.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)Indicates if this dimension is semantically identical to an object.Factor[]getFactors()Returns the array of Factor-s constituting this dimension.intgetRank()Returns the rank of this dimension.inthashCode()Returns the hash code of this instance.booleanisDimensionless()Indicates if this dimension is dimensionless.booleanisReciprocalOf(Dimension that)Indicates if this Dimension is the reciprocal of another dimension.protected Factor[]mult(Dimension that)Multiplies this dimension by another dimension.protected Factor[]pow(int power)Raises this dimension to a power.StringtoString()Returns the string representation of this dimension.
-
-
-
Field Detail
-
_factors
protected final Factor[] _factors
The individual elements of this dimension.
-
-
Constructor Detail
-
Dimension
public Dimension()
Constructs a dimensionless dimension from nothing.
-
Dimension
protected Dimension(Factor factor)
Constructs from a single Factor.- Parameters:
factor- The single Factor that defines the dimension.
-
Dimension
protected Dimension(Factor[] factors)
Constructs from an array of Factor-s. This is a trusted constructor for use by subclasses only.- Parameters:
factors- The factors that define the dimension.
-
-
Method Detail
-
getRank
public final int getRank()
Returns the rank of this dimension. The rank is the number of base entity and exponent pairs (i.e. the number of Factor-s constituting this dimension).- Returns:
- The rank of this dimension.
-
getFactors
public final Factor[] getFactors()
Returns the array of Factor-s constituting this dimension.- Returns:
- The array of Factor-s constituting this dimension.
-
mult
protected Factor[] mult(Dimension that)
Multiplies this dimension by another dimension.- Parameters:
that- The other dimension.- Returns:
- The product of the Factor-s of this dimension and the Factor-s of the other dimension.
-
pow
protected Factor[] pow(int power)
Raises this dimension to a power.- Parameters:
power- The power to raise this dimension by.- Returns:
- The Factor-s of this dimension raised to the power
power.
-
isReciprocalOf
public final boolean isReciprocalOf(Dimension that)
Indicates if this Dimension is the reciprocal of another dimension.- Parameters:
that- The other dimension.- Returns:
trueif and only if this dimension is the reciprocal of the other dimension.
-
equals
public final boolean equals(Object object)
Indicates if this dimension is semantically identical to an object.
-
hashCode
public int hashCode()
Returns the hash code of this instance.
-
isDimensionless
public final boolean isDimensionless()
Indicates if this dimension is dimensionless. A dimension is dimensionless if it has no Factor-s or if all Factor-s are, themselves, dimensionless.- Returns:
trueif and only if this dimension is dimensionless.
-
-