Package ucar.units

Class 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Factor[] _factors
      The individual elements of this dimension.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        Dimension()
      Constructs a dimensionless dimension from nothing.
      protected Dimension​(Factor factor)
      Constructs from a single Factor.
      protected Dimension​(Factor[] factors)
      Constructs from an array of Factor-s.
    • 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:
        true if 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.
        Overrides:
        equals in class Object
        Parameters:
        object - The object.
        Returns:
        true if and only if this dimension is semantically identical to object.
      • hashCode

        public int hashCode()
        Returns the hash code of this instance.
        Overrides:
        hashCode in class Object
        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:
        true if and only if this dimension is dimensionless.
      • toString

        public String toString()
        Returns the string representation of this dimension.
        Overrides:
        toString in class Object
        Returns:
        The string representation of this dimension.