Package ucar.units

Class BaseUnit

    • 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 return null.
        baseQuantity - The base quantity of the base unit.
        Throws:
        NameException - id.getSymbol() returned null.
    • 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 return null.
        baseQuantity - The base quantity of the base unit.
        Throws:
        NameException - id.getSymbol() returned null.
        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 to getSymbol().
        Specified by:
        getID in interface Base
        Returns:
        The identifier for this base unit.
      • toString

        public final String toString()
        Returns the string representation of this base unit. This is identical to getID().
        Specified by:
        toString in interface Unit
        Overrides:
        toString in class DerivedUnitImpl
        Returns:
        The string representation of this base unit.