org.ka2ddo.util
Enum TemperatureUnit

java.lang.Object
  extended by java.lang.Enum<TemperatureUnit>
      extended by org.ka2ddo.util.TemperatureUnit
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TemperatureUnit>, UnitEnum<TemperatureUnit>

public enum TemperatureUnit
extends java.lang.Enum<TemperatureUnit>
implements UnitEnum<TemperatureUnit>

This enumeration declares units (with conversion factors) for measuring temperatures. The default internal temperature units for APRS are degrees Fahrenheit, because that is what is specified by the message protocols.


Enum Constant Summary
C
          Temperature in degrees Celsius.
F
          Temperature in degrees Fahrenheit.
K
          Temperature in degrees Kelvin.
 
Method Summary
 float from(TemperatureUnit other)
          Get the multiplicative conversion factor to convert a value from the specified units to this unit.
 float fromFahrenheit(float tempF)
          Convert the specified temperature from this unit to Fahrenheit.
 float getOffset(TemperatureUnit other)
          Get the additive offset to convert a value from the specified unit to this unit.
 float toFahrenheit(float temp)
          Convert the specified temperature from this unit to Fahrenheit.
 java.lang.String unitString()
          Get the string to use when displaying values of this unit.
static TemperatureUnit valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static TemperatureUnit[] 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, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

F

public static final TemperatureUnit F
Temperature in degrees Fahrenheit.


C

public static final TemperatureUnit C
Temperature in degrees Celsius.


K

public static final TemperatureUnit K
Temperature in degrees Kelvin.

Method Detail

values

public static TemperatureUnit[] 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 (TemperatureUnit c : TemperatureUnit.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static TemperatureUnit 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

toFahrenheit

public final float toFahrenheit(float temp)
Convert the specified temperature from this unit to Fahrenheit.

Parameters:
temp - temperature in the units of this TemperatureUnit
Returns:
temperature in degrees Fahrenheit

fromFahrenheit

public final float fromFahrenheit(float tempF)
Convert the specified temperature from this unit to Fahrenheit.

Parameters:
tempF - temperature in degrees Fahrenheit
Returns:
temperature in the units of this TemperatureUnit

unitString

public final java.lang.String unitString()
Get the string to use when displaying values of this unit.

Returns:
suffix display String

from

public float from(TemperatureUnit other)
Get the multiplicative conversion factor to convert a value from the specified units to this unit.

Specified by:
from in interface UnitEnum<TemperatureUnit>
Parameters:
other - another TemperatureUnit representing the existing units of a value
Returns:
the conversion factor to change a value into this unit

getOffset

public float getOffset(TemperatureUnit other)
Get the additive offset to convert a value from the specified unit to this unit.

Specified by:
getOffset in interface UnitEnum<TemperatureUnit>
Parameters:
other - another TemperatureUnit representing the existing units of a value
Returns:
the offset (after multiplying by the from() factor) to add to get the value in this unit