Package ucar.units

Class DerivedUnitImpl

    • Field Detail

      • DIMENSIONLESS

        public static final DerivedUnitImpl DIMENSIONLESS
        The dimensionless derived unit.
    • Constructor Detail

      • DerivedUnitImpl

        protected DerivedUnitImpl()
        Constructs a dimensionless derived unit from nothing.
      • DerivedUnitImpl

        protected DerivedUnitImpl​(UnitDimension dimension)
        Constructs from a unit dimension. This is a trusted constructor for use by subclasses only.
        Parameters:
        dimension - The unit dimension.
      • DerivedUnitImpl

        protected DerivedUnitImpl​(UnitName id)
        Constructs from identifiers. This is a trusted constructor for use by subclasses only.
        Parameters:
        id - The identifiers for the unit.
      • DerivedUnitImpl

        protected DerivedUnitImpl​(UnitDimension dimension,
                                  UnitName id)
        Constructs from a unit dimension and identifiers. This is a trusted constructor for use by subclasses only.
        Parameters:
        dimension - The unit dimension.
        id - The identifiers for the unit.
    • Method Detail

      • setDimension

        protected void setDimension​(UnitDimension dimension)
        Sets the unit dimension of this derived unit. This is a trusted method for use by subclasses only and should be called only once immediately after construction of this superinstance.
        Parameters:
        dimension - The unit dimension.
      • getDimension

        public final UnitDimension getDimension()
        Returns the unit dimension of this derived unit.
        Specified by:
        getDimension in interface DerivedUnit
        Returns:
        The unit dimension of this derived unit.
      • getQuantityDimension

        public final QuantityDimension getQuantityDimension()
        Returns the quantity dimension of this derived unit.
        Specified by:
        getQuantityDimension in interface DerivedUnit
        Returns:
        The quantity dimension of this derived unit.
      • isReciprocalOf

        public final boolean isReciprocalOf​(DerivedUnit that)
        Indicates if this derived unit is the reciprocal of another derived unit (e.g. "second" and "hertz").
        Specified by:
        isReciprocalOf in interface DerivedUnit
        Parameters:
        that - The other, derived unit.
      • getDerivedUnit

        public final DerivedUnit getDerivedUnit()
        Returns the derived unit that is convertible with this unit. Obviously, the method returns this derived unit.
        Specified by:
        getDerivedUnit in interface DerivableUnit
        Specified by:
        getDerivedUnit in interface Unit
        Returns:
        this.
      • clone

        public final Unit clone​(UnitName id)
        Clones the derived unit changing the identifiers.
        Specified by:
        clone in interface Unit
        Parameters:
        id - The identifiers for the new unit.
        Returns:
        The new unit.
      • myRaiseTo

        protected Unit myRaiseTo​(int power)
        Raises this derived unit to a power.
        Specified by:
        myRaiseTo in class UnitImpl
        Parameters:
        power - The power.
        Returns:
        This derived unit raised to the given power.
      • toDerivedUnit

        public final float toDerivedUnit​(float amount)
        Converts a numerical value from this unit to the derived unit. Obviously, the numerical value is unchanged.
        Specified by:
        toDerivedUnit in interface DerivableUnit
        Parameters:
        amount - The numerical values in this unit.
        Returns:
        The numerical value in the derived unit.
      • toDerivedUnit

        public final double toDerivedUnit​(double amount)
        Converts a numerical value from this unit to the derived unit. Obviously, the numerical value is unchanged.
        Specified by:
        toDerivedUnit in interface DerivableUnit
        Parameters:
        amount - The numerical values in this unit.
        Returns:
        The numerical value in the derived unit.
      • toDerivedUnit

        public final float[] toDerivedUnit​(float[] input,
                                           float[] output)
        Converts numerical values from this unit to the derived unit. Obviously, the numerical values are unchanged.
        Specified by:
        toDerivedUnit in interface DerivableUnit
        Parameters:
        input - The numerical values in this unit.
        output - The numerical values in the derived unit. May be the same array as input.
        Returns:
        output.
      • toDerivedUnit

        public final double[] toDerivedUnit​(double[] input,
                                            double[] output)
        Converts numerical values from this unit to the derived unit. Obviously, the numerical values are unchanged.
        Specified by:
        toDerivedUnit in interface DerivableUnit
        Parameters:
        input - The numerical values in this unit.
        output - The numerical values in the derived unit. May be the same array as input.
        Returns:
        output.
      • fromDerivedUnit

        public final float fromDerivedUnit​(float amount)
        Converts a numerical value to this unit from the derived unit. Obviously, the numerical value is unchanged.
        Specified by:
        fromDerivedUnit in interface DerivableUnit
        Parameters:
        amount - The numerical values in the derived unit.
        Returns:
        The numerical value in this unit.
      • fromDerivedUnit

        public final double fromDerivedUnit​(double amount)
        Converts a numerical value to this unit from the derived unit. Obviously, the numerical value is unchanged.
        Specified by:
        fromDerivedUnit in interface DerivableUnit
        Parameters:
        amount - The numerical values in the derived unit.
        Returns:
        The numerical value in this unit.
      • fromDerivedUnit

        public final float[] fromDerivedUnit​(float[] input,
                                             float[] output)
        Converts numerical values to this unit from the derived unit. Obviously, the numerical values are unchanged.
        Specified by:
        fromDerivedUnit in interface DerivableUnit
        Parameters:
        input - The numerical values in the derived unit.
        output - The numerical values in this unit. May be the same array as input.
        Returns:
        output.
      • fromDerivedUnit

        public final double[] fromDerivedUnit​(double[] input,
                                              double[] output)
        Converts numerical values to this unit from the derived unit. Obviously, the numerical values are unchanged.
        Specified by:
        fromDerivedUnit in interface DerivableUnit
        Parameters:
        input - The numerical values in the derived unit.
        output - The numerical values in this unit. May be the same array as input.
        Returns:
        output.
      • isCompatible

        public final boolean isCompatible​(Unit that)
        Indicates if values in this unit are convertible with another unit.
        Specified by:
        isCompatible in interface Unit
        Overrides:
        isCompatible in class UnitImpl
        Parameters:
        that - The other unit.
        Returns:
        true if and only if values in this unit are convertible to values in that.
      • equals

        public boolean equals​(Object object)
        Indicates if this derived unit is semantically identical to an object.
        Specified by:
        equals in interface Unit
        Overrides:
        equals in class Object
        Parameters:
        object - The object
        Returns:
        true if and only if this derived unit is semantically identical to object.
      • hashCode

        public int hashCode()
        Returns the hash code of this instance.
        Specified by:
        hashCode in class UnitImpl
        Returns:
        The hash code of this instance.
      • isDimensionless

        public boolean isDimensionless()
        Indicates if this derived unit is dimensionless.
        Specified by:
        isDimensionless in interface Unit
        Returns:
        true if and only if this derived unit is dimensionless.
      • toString

        public String toString()
        Returns a string representation of this unit. If the symbol or name is available, then that is returned; otherwise, the corresponding expression in base units is returned.
        Specified by:
        toString in interface Unit
        Overrides:
        toString in class UnitImpl
        Returns:
        The string expression for this derived unit.
      • getCanonicalString

        public String getCanonicalString()
        Returns the canonical string representation of the unit.
        Specified by:
        getCanonicalString in interface Unit
        Returns:
        The canonical string representation.