Enum SIUnit

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      AMPERE
      Unit for electric current.
      BIT
      Unit for computer byte subdivision.
      BYTE
      Unit for computer memory.
      CANDELA
      Unit for luminous intensity.
      GRAM
      Unit for mass.
      KELVIN
      Unit for thermodynamic temperature.
      METRE
      Unit for length.
      MOLE
      Unit for amount of substance.
      SECOND
      Unit for time.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(long value)
      Formats the given value in the default locale for this unit.
      java.lang.String format​(long value, SIPrefix minPrefix)
      Formats the given value in the default locale for this unit.
      java.lang.String format​(long value, java.util.Locale locale)
      Formats the given value in the given locale for this unit.
      java.lang.String format​(long value, java.util.Locale locale, SIPrefix minPrefix)
      Formats the given value in the given locale for this unit.
      java.lang.String format​(java.math.BigDecimal value)
      Formats the given value in the default locale for this unit.
      java.lang.String format​(java.math.BigDecimal value, SIPrefix minPrefix)
      Formats the given value in the default locale for this unit.
      java.lang.String format​(java.math.BigDecimal value, java.util.Locale locale)
      Formats the given value in the given locale for this unit.
      java.lang.String format​(java.math.BigDecimal value, java.util.Locale locale, SIPrefix minPrefix)
      Formats the given value in the given locale for this unit.
      java.lang.String getSymbol()  
      java.lang.String toString()
      Returns a string representation of the unit.
      static SIUnit valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static SIUnit[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • METRE

        public static final SIUnit METRE
        Unit for length.
      • GRAM

        public static final SIUnit GRAM
        Unit for mass.
      • SECOND

        public static final SIUnit SECOND
        Unit for time.
      • AMPERE

        public static final SIUnit AMPERE
        Unit for electric current.
      • KELVIN

        public static final SIUnit KELVIN
        Unit for thermodynamic temperature.
      • MOLE

        public static final SIUnit MOLE
        Unit for amount of substance.
      • CANDELA

        public static final SIUnit CANDELA
        Unit for luminous intensity.
      • BYTE

        public static final SIUnit BYTE
        Unit for computer memory.
      • BIT

        public static final SIUnit BIT
        Unit for computer byte subdivision.
    • Method Detail

      • values

        public static SIUnit[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (SIUnit c : SIUnit.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static SIUnit valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getSymbol

        public java.lang.String getSymbol()
        Returns:
        The unit symbol, or null if this unit has no symbol.
      • toString

        public java.lang.String toString()
        Returns a string representation of the unit. This version returns the unit symbol.
        Overrides:
        toString in class java.lang.Enum<SIUnit>
        See Also:
        getSymbol()
      • format

        public java.lang.String format​(long value)
        Formats the given value in the default locale for this unit.

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        Returns:
        A string representation of the given value in the default local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(long value,
                                       java.util.Locale locale)
        Formats the given value in the given locale for this unit.

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        locale - The locale used for formatting.
        Returns:
        A string representation of the given value in the given local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(long value,
                                       SIPrefix minPrefix)
        Formats the given value in the default locale for this unit.

        If a minimum prefix is given and the appropriate prefix is smaller than the given prefix, a prefix of SIPrefix.NONE is used. For example, formatting a METRE quantity of -100 would yield "1cm", but a BYTE quantity of 100 with a minimum prefix of SIPrefix.KILO would yield "100b".

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        minPrefix - The minimum prefix to use without resorting to SIPrefix.NONE, or null if there is no minimum prefix.
        Returns:
        A string representation of the given value in the default local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(long value,
                                       java.util.Locale locale,
                                       SIPrefix minPrefix)
        Formats the given value in the given locale for this unit.

        If a minimum prefix is given and the appropriate prefix is smaller than the given prefix, a prefix of SIPrefix.NONE is used. For example, formatting a METRE quantity of -100 would yield "1cm", but a BYTE quantity of 100 with a minimum prefix of SIPrefix.KILO would yield "100b".

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        locale - The locale used for formatting.
        minPrefix - The minimum prefix to use without resorting to SIPrefix.NONE, or null if there is no minimum prefix.
        Returns:
        A string representation of the given value in the given local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(java.math.BigDecimal value)
        Formats the given value in the default locale for this unit.

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        Returns:
        A string representation of the given value in the default local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(java.math.BigDecimal value,
                                       java.util.Locale locale)
        Formats the given value in the given locale for this unit.

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        locale - The locale used for formatting.
        Returns:
        A string representation of the given value in the given local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(java.math.BigDecimal value,
                                       SIPrefix minPrefix)
        Formats the given value in the default locale for this unit.

        If a minimum prefix is given and the appropriate prefix is smaller than the given prefix, a prefix of SIPrefix.NONE is used. For example, formatting a METRE quantity of -100 would yield "1cm", but a BYTE quantity of 100 with a minimum prefix of SIPrefix.KILO would yield "100b".

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        minPrefix - The minimum prefix to use without resorting to SIPrefix.NONE, or null if there is no minimum prefix.
        Returns:
        A string representation of the given value in the default local in this unit with the highest available prefix.
      • format

        public java.lang.String format​(java.math.BigDecimal value,
                                       java.util.Locale locale,
                                       SIPrefix minPrefix)
        Formats the given value in the given locale for this unit.

        If a minimum prefix is given and the appropriate prefix is smaller than the given prefix, a prefix of SIPrefix.NONE is used. For example, formatting a METRE quantity of -100 would yield "1cm", but a BYTE quantity of 100 with a minimum prefix of SIPrefix.KILO would yield "100b".

        Rounding is performed down so as not to cause discrepancies between the value and the determined prefix.

        Parameters:
        value - The value to format.
        locale - The locale used for formatting.
        minPrefix - The minimum prefix to use without resorting to SIPrefix.NONE, or null if there is no minimum prefix.
        Returns:
        A string representation of the given value in the given local in this unit with the highest available prefix.